VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "itgcontrols.ocx"
Begin VB.Form frmARSalesOrder 
   BackColor       =   &H00F7D9C2&
   BorderStyle     =   0  'None
   Caption         =   "Sample"
   ClientHeight    =   8640
   ClientLeft      =   -90
   ClientTop       =   465
   ClientWidth     =   11685
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "frmARSalesOrder.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   8640
   ScaleWidth      =   11685
   ShowInTaskbar   =   0   'False
   Begin MSComctlLib.StatusBar sbRS 
      Align           =   2  'Align Bottom
      Height          =   285
      Left            =   0
      TabIndex        =   73
      Top             =   8355
      Width           =   11685
      _ExtentX        =   20611
      _ExtentY        =   503
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   5
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Alignment       =   1
            AutoSize        =   1
            Bevel           =   0
            Object.Width           =   7384
            MinWidth        =   2
         EndProperty
         BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel5 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin ITGControls.ComunionFrames ComunionFrames2 
      Height          =   2895
      Left            =   0
      Top             =   3750
      Width           =   11550
      _ExtentX        =   20373
      _ExtentY        =   5106
      FrameColor      =   4210752
      BackColor       =   16243138
      FillColor       =   16243138
      RoundedCorner   =   0   'False
      Caption         =   "Details"
      Alignment       =   0
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ThemeColor      =   5
      ColorFrom       =   16243138
      ColorTo         =   16250865
      Begin VB.TextBox txtLongDesc 
         Appearance      =   0  'Flat
         DataField       =   "cLongDesc"
         Height          =   1215
         Left            =   1740
         MaxLength       =   1000
         MultiLine       =   -1  'True
         TabIndex        =   78
         Top             =   1200
         Visible         =   0   'False
         Width           =   4065
      End
      Begin VB.ComboBox cboSO 
         Height          =   315
         ItemData        =   "frmARSalesOrder.frx":0CCA
         Left            =   315
         List            =   "frmARSalesOrder.frx":0CCC
         Style           =   2  'Dropdown List
         TabIndex        =   77
         Top             =   1590
         Visible         =   0   'False
         Width           =   1395
      End
      Begin MSDataGridLib.DataGrid dtgSO 
         Height          =   2475
         Left            =   0
         TabIndex        =   20
         Top             =   420
         Width           =   11550
         _ExtentX        =   20373
         _ExtentY        =   4366
         _Version        =   393216
         AllowUpdate     =   -1  'True
         AllowArrows     =   -1  'True
         Appearance      =   0
         BackColor       =   16777215
         HeadLines       =   1
         RowHeight       =   15
         TabAcrossSplits =   -1  'True
         TabAction       =   2
         FormatLocked    =   -1  'True
         AllowDelete     =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   19
         BeginProperty Column00 
            DataField       =   "cSONo"
            Caption         =   "Sales Order ID"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   3
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "cItemNo"
            Caption         =   "Product ID"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "cDesc"
            Caption         =   "Product Description"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "cUnit"
            Caption         =   "Unit"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "nQty"
            Caption         =   "Quantity"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column05 
            DataField       =   "cPricing"
            Caption         =   "Pricing"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "#,##0.00000000"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column06 
            DataField       =   "nPrice"
            Caption         =   "Price"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column07 
            DataField       =   "cDiscount"
            Caption         =   "Discount"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "0"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column08 
            DataField       =   "nNetPrice"
            Caption         =   "Net Price"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.0000"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column09 
            DataField       =   "nAmount"
            Caption         =   "Amount"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column10 
            DataField       =   "cStatus"
            Caption         =   "Product Status"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "M/d/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column11 
            DataField       =   "dDelDate"
            Caption         =   "Delivery Date"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   3
            EndProperty
         EndProperty
         BeginProperty Column12 
            DataField       =   "nSMCom"
            Caption         =   "Com %"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column13 
            DataField       =   "cRefNo"
            Caption         =   "Reference No."
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column14 
            DataField       =   "cWH"
            Caption         =   "Warehouse"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column15 
            DataField       =   "cBarcodeID"
            Caption         =   "Internal Barcode ID"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column16 
            DataField       =   "cCustCode"
            Caption         =   "Customer Code"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column17 
            DataField       =   "cSKU"
            Caption         =   "Barcode/SKU"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column18 
            DataField       =   "nFactor"
            Caption         =   "Factor"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   13321
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
               Button          =   -1  'True
               Locked          =   -1  'True
               Object.Visible         =   0   'False
               ColumnWidth     =   1124.787
            EndProperty
            BeginProperty Column01 
               Button          =   -1  'True
               ColumnWidth     =   1275.024
            EndProperty
            BeginProperty Column02 
               Button          =   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   2385.071
            EndProperty
            BeginProperty Column03 
               Button          =   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   794.835
            EndProperty
            BeginProperty Column04 
               Alignment       =   1
               ColumnWidth     =   989.858
            EndProperty
            BeginProperty Column05 
               Button          =   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   1019.906
            EndProperty
            BeginProperty Column06 
               Alignment       =   1
               Button          =   -1  'True
               ColumnWidth     =   989.858
            EndProperty
            BeginProperty Column07 
               Object.Visible         =   -1  'True
               ColumnWidth     =   975.118
            EndProperty
            BeginProperty Column08 
               Alignment       =   1
               Locked          =   -1  'True
               ColumnWidth     =   1094.74
            EndProperty
            BeginProperty Column09 
               Alignment       =   1
               Locked          =   -1  'True
               Object.Visible         =   -1  'True
               ColumnWidth     =   1154.835
            EndProperty
            BeginProperty Column10 
               Button          =   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   1305.071
            EndProperty
            BeginProperty Column11 
               ColumnWidth     =   1244.976
            EndProperty
            BeginProperty Column12 
               Alignment       =   1
               Object.Visible         =   0   'False
               ColumnWidth     =   615.118
            EndProperty
            BeginProperty Column13 
               Locked          =   -1  'True
               ColumnWidth     =   1049.953
            EndProperty
            BeginProperty Column14 
               Button          =   -1  'True
               ColumnWidth     =   1065.26
            EndProperty
            BeginProperty Column15 
               Object.Visible         =   0   'False
            EndProperty
            BeginProperty Column16 
               Object.Visible         =   0   'False
            EndProperty
            BeginProperty Column17 
               Object.Visible         =   0   'False
            EndProperty
            BeginProperty Column18 
               ColumnWidth     =   14.74
            EndProperty
         EndProperty
      End
   End
   Begin ITGControls.ITGTab SSTab1 
      Height          =   7950
      Left            =   0
      TabIndex        =   60
      Top             =   0
      Width           =   11565
      _ExtentX        =   20399
      _ExtentY        =   14023
      TabCount        =   2
      TabCaption(0)   =   "               Main               "
      TabContCtrlCnt(0)=   6
      Tab(0)ContCtrlCap(1)=   "ComunionFrames1"
      Tab(0)ContCtrlCap(2)=   "txtNet"
      Tab(0)ContCtrlCap(3)=   "txtDiscount"
      Tab(0)ContCtrlCap(4)=   "txtGross"
      Tab(0)ContCtrlCap(5)=   "cmdServe"
      Tab(0)ContCtrlCap(6)=   "lblStatus"
      TabCaption(1)   =   "               List               "
      TabContCtrlCnt(1)=   1
      Tab(1)ContCtrlCap(1)=   "dtgList"
      TabStyle        =   1
      TabTheme        =   2
      ActiveTabBackStartColor=   16250865
      ActiveTabBackEndColor=   16243138
      InActiveTabBackStartColor=   16243138
      InActiveTabBackEndColor=   16243138
      ActiveTabForeColor=   0
      InActiveTabForeColor=   0
      BeginProperty ActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty InActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      OuterBorderColor=   4210752
      TopLeftInnerBorderColor=   4210752
      BottomRightInnerBorderColor=   4210752
      DisabledTabBackColor=   -2147483633
      DisabledTabForeColor=   -2147483627
      Begin ITGControls.ComunionFrames ComunionFrames1 
         Height          =   3450
         Left            =   0
         Top             =   315
         Width           =   11565
         _ExtentX        =   20399
         _ExtentY        =   6085
         FrameColor      =   4210752
         BackColor       =   16243138
         FillColor       =   16243138
         RoundedCorner   =   0   'False
         Caption         =   "Information"
         Alignment       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ThemeColor      =   5
         ColorFrom       =   16243138
         ColorTo         =   16250865
         Begin VB.Timer Timer1 
            Interval        =   300
            Left            =   2670
            Top             =   495
         End
         Begin VB.ComboBox cboType 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            Height          =   315
            ItemData        =   "frmARSalesOrder.frx":0CCE
            Left            =   8640
            List            =   "frmARSalesOrder.frx":0CE1
            Style           =   2  'Dropdown List
            TabIndex        =   2
            Top             =   480
            Width           =   1605
         End
         Begin ITGControls.ITGTextBox txtType 
            Height          =   285
            Left            =   7530
            TabIndex        =   72
            Tag             =   "cboType"
            Top             =   510
            Width           =   2340
            _ExtentX        =   3916
            _ExtentY        =   503
            BackColor       =   16243138
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Mandatory       =   -1  'True
            Label           =   "Order Type"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1200
            TextBoxWidth    =   1080
            Required        =   -1  'True
         End
         Begin ITGControls.ITGDateBox dtbDate 
            Height          =   285
            Left            =   5415
            TabIndex        =   1
            Tag             =   "Order Date"
            Top             =   480
            Width           =   1275
            _ExtentX        =   2249
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   ""
            SendKeysTab     =   -1  'True
            Mandatory       =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtSONo 
            Height          =   285
            Left            =   135
            TabIndex        =   0
            Top             =   480
            Width           =   2535
            _ExtentX        =   4260
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Sales Order No."
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1325
            TextBoxWidth    =   1150
            Required        =   -1  'True
         End
         Begin ITGControls.ITGTab SSTab2 
            Height          =   2445
            Left            =   0
            TabIndex        =   63
            Top             =   1005
            Width           =   11550
            _ExtentX        =   20373
            _ExtentY        =   4313
            TabCount        =   4
            TabCaption(0)   =   "Order by"
            TabContCtrlCnt(0)=   23
            Tab(0)ContCtrlCap(1)=   "txtAddTo"
            Tab(0)ContCtrlCap(2)=   "txtAddToName"
            Tab(0)ContCtrlCap(3)=   "cmdPickAddTo"
            Tab(0)ContCtrlCap(4)=   "txtPromo"
            Tab(0)ContCtrlCap(5)=   "txtPromoName"
            Tab(0)ContCtrlCap(6)=   "cmdPickEmp"
            Tab(0)ContCtrlCap(7)=   "cmdPickSM"
            Tab(0)ContCtrlCap(8)=   "cmdPickCode"
            Tab(0)ContCtrlCap(9)=   "cboIntTerms"
            Tab(0)ContCtrlCap(10)=   "cboTerms"
            Tab(0)ContCtrlCap(11)=   "cboPaymentType"
            Tab(0)ContCtrlCap(12)=   "txtTerms"
            Tab(0)ContCtrlCap(13)=   "txtPaymentType"
            Tab(0)ContCtrlCap(14)=   "txtIntTerms"
            Tab(0)ContCtrlCap(15)=   "txtCode"
            Tab(0)ContCtrlCap(16)=   "txtAddress"
            Tab(0)ContCtrlCap(17)=   "txtContact"
            Tab(0)ContCtrlCap(18)=   "txtName"
            Tab(0)ContCtrlCap(19)=   "txtSMName"
            Tab(0)ContCtrlCap(20)=   "txtSMCode"
            Tab(0)ContCtrlCap(21)=   "Label3"
            Tab(0)ContCtrlCap(22)=   "Label2"
            Tab(0)ContCtrlCap(23)=   "Label41"
            TabCaption(1)   =   "Other Information"
            TabContCtrlCnt(1)=   17
            Tab(1)ContCtrlCap(1)=   "cmdPickDCode"
            Tab(1)ContCtrlCap(2)=   "cmdPickMS"
            Tab(1)ContCtrlCap(3)=   "cboCurrency"
            Tab(1)ContCtrlCap(4)=   "cmdPickPC"
            Tab(1)ContCtrlCap(5)=   "txtMSCode"
            Tab(1)ContCtrlCap(6)=   "txtMSDesc"
            Tab(1)ContCtrlCap(7)=   "txtPCDesc"
            Tab(1)ContCtrlCap(8)=   "txtPCCode"
            Tab(1)ContCtrlCap(9)=   "dtgExpiration"
            Tab(1)ContCtrlCap(10)=   "txtCurrency"
            Tab(1)ContCtrlCap(11)=   "txtCurrencyRate"
            Tab(1)ContCtrlCap(12)=   "txtCPONo"
            Tab(1)ContCtrlCap(13)=   "txtRemarks"
            Tab(1)ContCtrlCap(14)=   "txtDCode"
            Tab(1)ContCtrlCap(15)=   "txtDName"
            Tab(1)ContCtrlCap(16)=   "Label40"
            Tab(1)ContCtrlCap(17)=   "Label1"
            TabCaption(2)   =   "Delivered To"
            TabContCtrlCnt(2)=   9
            Tab(2)ContCtrlCap(1)=   "cmdPickDelCode"
            Tab(2)ContCtrlCap(2)=   "txtDelName"
            Tab(2)ContCtrlCap(3)=   "txtDelCode"
            Tab(2)ContCtrlCap(4)=   "txtDelAddress"
            Tab(2)ContCtrlCap(5)=   "txtDelContact"
            Tab(2)ContCtrlCap(6)=   "txtFax"
            Tab(2)ContCtrlCap(7)=   "txtEMail1"
            Tab(2)ContCtrlCap(8)=   "txtPhone1"
            Tab(2)ContCtrlCap(9)=   "txtPhone2"
            TabCaption(3)   =   "Forwarder"
            TabContCtrlCnt(3)=   14
            Tab(3)ContCtrlCap(1)=   "cmdPickDestination"
            Tab(3)ContCtrlCap(2)=   "cmdPickTrucker"
            Tab(3)ContCtrlCap(3)=   "txtTruckerName"
            Tab(3)ContCtrlCap(4)=   "txtTruckerCode"
            Tab(3)ContCtrlCap(5)=   "txtTruckerAdd"
            Tab(3)ContCtrlCap(6)=   "txtTruckerContact"
            Tab(3)ContCtrlCap(7)=   "txtTruckerTel"
            Tab(3)ContCtrlCap(8)=   "txtTruckerFax"
            Tab(3)ContCtrlCap(9)=   "txtTruckerDest"
            Tab(3)ContCtrlCap(10)=   "txtTruckerLine"
            Tab(3)ContCtrlCap(11)=   "dtbShipping"
            Tab(3)ContCtrlCap(12)=   "txtTruckerVessel"
            Tab(3)ContCtrlCap(13)=   "txtTruckerType"
            Tab(3)ContCtrlCap(14)=   "Label5"
            TabTheme        =   2
            ActiveTabBackStartColor=   16250865
            ActiveTabBackEndColor=   16243138
            InActiveTabBackStartColor=   16243138
            InActiveTabBackEndColor=   16243138
            ActiveTabForeColor=   0
            InActiveTabForeColor=   0
            BeginProperty ActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            BeginProperty InActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            OuterBorderColor=   4210752
            TopLeftInnerBorderColor=   4210752
            BottomRightInnerBorderColor=   4210752
            DisabledTabBackColor=   16243138
            DisabledTabForeColor=   -2147483627
            HoverColorInverted=   4210752
            Begin ITGControls.ITGTextBox txtAddTo 
               Height          =   285
               Left            =   150
               TabIndex        =   17
               Top             =   1965
               Width           =   2520
               _ExtentX        =   4233
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14745599
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               AllCaps         =   -1  'True
               Mandatory       =   -1  'True
               Label           =   "Addressed to"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1325
               TextBoxWidth    =   1135
               Required        =   -1  'True
               LinkForeColor   =   16711680
            End
            Begin ITGControls.ITGTextBox txtAddToName 
               Height          =   285
               Left            =   3030
               TabIndex        =   19
               TabStop         =   0   'False
               Top             =   1965
               Width           =   3810
               _ExtentX        =   6615
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14737632
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               AllCaps         =   -1  'True
               Label           =   "ITGtext"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   0
               TextBoxWidth    =   3750
               Enabled         =   0   'False
            End
            Begin VB.CommandButton cmdPickAddTo 
               Height          =   300
               Left            =   2700
               Picture         =   "frmARSalesOrder.frx":0D22
               Style           =   1  'Graphical
               TabIndex        =   18
               Top             =   1965
               Width           =   315
            End
            Begin ITGControls.ITGTextBox txtPromo 
               Height          =   285
               Left            =   150
               TabIndex        =   14
               Top             =   1650
               Width           =   2520
               _ExtentX        =   4233
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14745599
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               AllCaps         =   -1  'True
               Mandatory       =   -1  'True
               Label           =   "Requested by"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1325
               TextBoxWidth    =   1135
               Required        =   -1  'True
               LinkForeColor   =   16711680
            End
            Begin ITGControls.ITGTextBox txtPromoName 
               Height          =   285
               Left            =   3030
               TabIndex        =   16
               TabStop         =   0   'False
               Top             =   1650
               Width           =   3810
               _ExtentX        =   6615
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14737632
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               AllCaps         =   -1  'True
               Label           =   "ITGtext"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   0
               TextBoxWidth    =   3750
               Enabled         =   0   'False
            End
            Begin VB.CommandButton cmdPickEmp 
               Height          =   300
               Left            =   2700
               Picture         =   "frmARSalesOrder.frx":0E6C
               Style           =   1  'Graphical
               TabIndex        =   15
               Top             =   1650
               Width           =   315
            End
            Begin VB.CommandButton cmdPickSM 
               Height          =   300
               Left            =   2700
               Picture         =   "frmARSalesOrder.frx":0FB6
               Style           =   1  'Graphical
               TabIndex        =   12
               Top             =   1335
               Width           =   315
            End
            Begin VB.CommandButton cmdPickCode 
               Height          =   300
               Left            =   2700
               Picture         =   "frmARSalesOrder.frx":1100
               Style           =   1  'Graphical
               TabIndex        =   4
               Top             =   390
               Width           =   315
            End
            Begin VB.ComboBox cboIntTerms 
               Appearance      =   0  'Flat
               BackColor       =   &H00FFFFFF&
               Height          =   315
               Left            =   8895
               Style           =   2  'Dropdown List
               TabIndex        =   6
               Top             =   390
               Width           =   1365
            End
            Begin VB.ComboBox cboTerms 
               Appearance      =   0  'Flat
               BackColor       =   &H00FFFFFF&
               Height          =   315
               Left            =   8895
               Style           =   2  'Dropdown List
               TabIndex        =   8
               Top             =   705
               Width           =   1365
            End
            Begin VB.ComboBox cboPaymentType 
               Appearance      =   0  'Flat
               BackColor       =   &H00FFFFFF&
               Height          =   315
               Left            =   8895
               Style           =   2  'Dropdown List
               TabIndex        =   10
               Top             =   1020
               Width           =   1365
            End
            Begin ITGControls.ITGTextBox txtTerms 
               Height          =   285
               Left            =   8925
               TabIndex        =   67
               Tag             =   "cboTerms"
               Top             =   795
               Visible         =   0   'False
               Width           =   1155
               _ExtentX        =   1931
               _ExtentY        =   503
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Mandatory       =   -1  'True
               Label           =   "Actual Terms"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   0
               TextBoxWidth    =   1095
            End
            Begin ITGControls.ITGTextBox txtPaymentType 
               Height          =   285
               Left            =   9060
               TabIndex        =   66
               Tag             =   "cboPayment"
               Top             =   855
               Visible         =   0   'False
               Width           =   1155
               _ExtentX        =   1931
               _ExtentY        =   503
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Mandatory       =   -1  'True
               Label           =   "Payment Type"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   0
               TextBoxWidth    =   1095
            End
            Begin ITGControls.ITGTextBox txtIntTerms 
               Height          =   285
               Left            =   8925
               TabIndex        =   65
               Tag             =   "cboIntTerms"
               Top             =   405
               Visible         =   0   'False
               Width           =   1155
               _ExtentX        =   1931
               _ExtentY        =   503
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Mandatory       =   -1  'True
               Label           =   "Internal Terms"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   0
               TextBoxWidth    =   1095
            End
            Begin ITGControls.ITGTextBox txtCode 
               Height          =   285
               Left            =   150
               TabIndex        =   3
               Top             =   390
               Width           =   2520
               _ExtentX        =   4233
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14745599
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               AllCaps         =   -1  'True
               Mandatory       =   -1  'True
               Label           =   "Customer"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1325
               TextBoxWidth    =   1135
               Required        =   -1  'True
               LinkForeColor   =   16711680
            End
            Begin ITGControls.ITGTextBox txtAddress 
               Height          =   285
               Left            =   150
               TabIndex        =   7
               Top             =   705
               Width           =   6690
               _ExtentX        =   11589
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Label           =   "Address"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1325
               TextBoxWidth    =   5305
               LinkForeColor   =   0
            End
            Begin ITGControls.ITGTextBox txtContact 
               Height          =   285
               Left            =   150
               TabIndex        =   9
               Top             =   1020
               Width           =   6690
               _ExtentX        =   11589
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Label           =   "Contact"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1325
               TextBoxWidth    =   5305
               LinkForeColor   =   0
            End
            Begin ITGControls.ITGTextBox txtName 
               Height          =   285
               Left            =   3030
               TabIndex        =   5
               TabStop         =   0   'False
               Top             =   390
               Width           =   3810
               _ExtentX        =   6615
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14737632
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               AllCaps         =   -1  'True
               Label           =   "ITGtext"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   0
               TextBoxWidth    =   3750
               Enabled         =   0   'False
            End
            Begin ITGControls.ITGTextBox txtSMName 
               Height          =   285
               Left            =   3030
               TabIndex        =   13
               TabStop         =   0   'False
               Top             =   1335
               Width           =   3810
               _ExtentX        =   6615
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14737632
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               AllCaps         =   -1  'True
               Label           =   "ITGtext"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   0
               TextBoxWidth    =   3750
               Enabled         =   0   'False
            End
            Begin ITGControls.ITGTextBox txtSMCode 
               Height          =   285
               Left            =   150
               TabIndex        =   11
               Top             =   1335
               Width           =   2520
               _ExtentX        =   4233
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14745599
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               AllCaps         =   -1  'True
               Mandatory       =   -1  'True
               Label           =   "Salesman"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1325
               TextBoxWidth    =   1135
               Required        =   -1  'True
               LinkForeColor   =   16711680
            End
            Begin VB.CommandButton cmdPickDCode 
               Enabled         =   0   'False
               Height          =   300
               Left            =   -72225
               Picture         =   "frmARSalesOrder.frx":124A
               Style           =   1  'Graphical
               TabIndex        =   29
               Top             =   705
               Width           =   315
            End
            Begin VB.CommandButton cmdPickMS 
               Height          =   300
               Left            =   -72225
               Picture         =   "frmARSalesOrder.frx":1394
               Style           =   1  'Graphical
               TabIndex        =   26
               Top             =   390
               Width           =   315
            End
            Begin VB.ComboBox cboCurrency 
               Appearance      =   0  'Flat
               BackColor       =   &H00FFFFFF&
               Height          =   315
               Left            =   -66015
               Style           =   2  'Dropdown List
               TabIndex        =   61
               Top             =   375
               Width           =   1500
            End
            Begin VB.CommandButton cmdPickPC 
               Height          =   300
               Left            =   -72225
               Picture         =   "frmARSalesOrder.frx":14DE
               Style           =   1  'Graphical
               TabIndex        =   33
               Top             =   1020
               Width           =   315
            End
            Begin ITGControls.ITGTextBox txtMSCode 
               Height          =   285
               Left            =   -74775
               TabIndex        =   25
               Top             =   390
               Width           =   2520
               _ExtentX        =   4233
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14745599
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Mandatory       =   -1  'True
               Label           =   "Market Segment"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1325
               TextBoxWidth    =   1135
               Required        =   -1  'True
            End
            Begin ITGControls.ITGTextBox txtMSDesc 
               Height          =   285
               Left            =   -71895
               TabIndex        =   27
               TabStop         =   0   'False
               Top             =   390
               Width           =   4005
               _ExtentX        =   6959
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14737632
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               AllCaps         =   -1  'True
               Label           =   "ITGtext"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   0
               TextBoxWidth    =   3945
               Enabled         =   0   'False
            End
            Begin ITGControls.ITGTextBox txtPCDesc 
               Height          =   285
               Left            =   -71895
               TabIndex        =   34
               TabStop         =   0   'False
               Top             =   1020
               Width           =   4005
               _ExtentX        =   6959
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14737632
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               AllCaps         =   -1  'True
               Label           =   "ITGtext"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   0
               TextBoxWidth    =   3945
               Enabled         =   0   'False
            End
            Begin ITGControls.ITGTextBox txtPCCode 
               Height          =   285
               Left            =   -74775
               TabIndex        =   32
               Top             =   1020
               Width           =   2520
               _ExtentX        =   4233
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Label           =   "Unit Division"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1325
               TextBoxWidth    =   1135
               Hover           =   -1  'True
               Required        =   -1  'True
               LinkForeColor   =   16711680
            End
            Begin ITGControls.ITGDateBox dtgExpiration 
               Height          =   285
               Left            =   -66015
               TabIndex        =   35
               Tag             =   "Order Date"
               Top             =   1020
               Width           =   1485
               _ExtentX        =   2619
               _ExtentY        =   503
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Text            =   ""
               SendKeysTab     =   -1  'True
               Mandatory       =   -1  'True
            End
            Begin ITGControls.ITGTextBox txtCurrency 
               Height          =   285
               Left            =   -65910
               TabIndex        =   64
               Top             =   375
               Visible         =   0   'False
               Width           =   1050
               _ExtentX        =   1746
               _ExtentY        =   503
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Label           =   "ITGtext"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   0
               TextBoxWidth    =   990
            End
            Begin ITGControls.ITGTextBox txtCurrencyRate 
               Height          =   285
               Left            =   -67365
               TabIndex        =   31
               Top             =   705
               Width           =   2835
               _ExtentX        =   4789
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Text            =   "0"
               DataType        =   1
               DecimalPlace    =   2
               Label           =   "Currency Rate"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1325
               TextBoxWidth    =   1450
               LinkForeColor   =   0
            End
            Begin ITGControls.ITGTextBox txtCPONo 
               Height          =   285
               Left            =   -67365
               TabIndex        =   37
               Top             =   1335
               Width           =   2820
               _ExtentX        =   4763
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Label           =   "Customer PO No."
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1325
               TextBoxWidth    =   1435
               LinkForeColor   =   0
            End
            Begin ITGControls.ITGTextBox txtRemarks 
               Height          =   285
               Left            =   -74775
               TabIndex        =   36
               Top             =   1335
               Width           =   6885
               _ExtentX        =   11933
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Label           =   "Remarks"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1325
               TextBoxWidth    =   5500
               LinkForeColor   =   0
            End
            Begin ITGControls.ITGTextBox txtDCode 
               Height          =   285
               Left            =   -74775
               TabIndex        =   28
               Top             =   705
               Width           =   2520
               _ExtentX        =   4233
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14745599
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Mandatory       =   -1  'True
               Label           =   "Distributor"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   -1  'True
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1325
               TextBoxWidth    =   1135
               Hover           =   -1  'True
               LinkForeColor   =   16711680
            End
            Begin ITGControls.ITGTextBox txtDName 
               Height          =   285
               Left            =   -71895
               TabIndex        =   30
               TabStop         =   0   'False
               Top             =   705
               Width           =   4005
               _ExtentX        =   6959
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14737632
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               AllCaps         =   -1  'True
               Label           =   "ITGtext"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   0
               TextBoxWidth    =   3945
               Enabled         =   0   'False
            End
            Begin VB.CommandButton cmdPickDelCode 
               Height          =   300
               Left            =   -72300
               Picture         =   "frmARSalesOrder.frx":1628
               Style           =   1  'Graphical
               TabIndex        =   39
               Top             =   390
               Width           =   315
            End
            Begin ITGControls.ITGTextBox txtDelName 
               Height          =   285
               Left            =   -71970
               TabIndex        =   40
               TabStop         =   0   'False
               Top             =   390
               Width           =   4005
               _ExtentX        =   6959
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14737632
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               AllCaps         =   -1  'True
               Label           =   "ITGtext"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   0
               TextBoxWidth    =   3945
               Enabled         =   0   'False
            End
            Begin ITGControls.ITGTextBox txtDelCode 
               Height          =   285
               Left            =   -74850
               TabIndex        =   38
               Top             =   390
               Width           =   2520
               _ExtentX        =   4233
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14745599
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Mandatory       =   -1  'True
               Label           =   "Customer"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   -1  'True
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1325
               TextBoxWidth    =   1135
               Hover           =   -1  'True
               LinkForeColor   =   16711680
            End
            Begin ITGControls.ITGTextBox txtDelAddress 
               Height          =   285
               Left            =   -74850
               TabIndex        =   42
               Top             =   705
               Width           =   6885
               _ExtentX        =   11933
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Label           =   "Address"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1325
               TextBoxWidth    =   5500
               LinkForeColor   =   0
            End
            Begin ITGControls.ITGTextBox txtDelContact 
               Height          =   285
               Left            =   -74850
               TabIndex        =   44
               Top             =   1020
               Width           =   6885
               _ExtentX        =   11933
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Label           =   "Contact"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1325
               TextBoxWidth    =   5500
               LinkForeColor   =   0
            End
            Begin ITGControls.ITGTextBox txtFax 
               Height          =   285
               Left            =   -67590
               TabIndex        =   45
               Tag             =   "C"
               Top             =   1020
               Width           =   3090
               _ExtentX        =   5239
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               MaxLength       =   20
               Label           =   "Fax"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   900
               TextBoxWidth    =   2130
            End
            Begin ITGControls.ITGTextBox txtEMail1 
               Height          =   285
               Left            =   -67590
               TabIndex        =   46
               Tag             =   "C"
               Top             =   1335
               Width           =   3090
               _ExtentX        =   5239
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               MaxLength       =   50
               Label           =   "E-Mail 01"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   900
               TextBoxWidth    =   2130
            End
            Begin ITGControls.ITGTextBox txtPhone1 
               Height          =   285
               Left            =   -67590
               TabIndex        =   41
               Tag             =   "C"
               Top             =   390
               Width           =   3090
               _ExtentX        =   5239
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               MaxLength       =   20
               Label           =   "Phone 01"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   900
               TextBoxWidth    =   2130
            End
            Begin ITGControls.ITGTextBox txtPhone2 
               Height          =   285
               Left            =   -67590
               TabIndex        =   43
               Tag             =   "C"
               Top             =   705
               Width           =   3090
               _ExtentX        =   5239
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               MaxLength       =   20
               Label           =   "Phone 02"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   900
               TextBoxWidth    =   2130
            End
            Begin VB.CommandButton cmdPickDestination 
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   300
               Left            =   -64755
               Picture         =   "frmARSalesOrder.frx":1772
               Style           =   1  'Graphical
               TabIndex        =   51
               Top             =   390
               Width           =   315
            End
            Begin VB.CommandButton cmdPickTrucker 
               Height          =   300
               Left            =   -72495
               Picture         =   "frmARSalesOrder.frx":18BC
               Style           =   1  'Graphical
               TabIndex        =   48
               Top             =   390
               Width           =   315
            End
            Begin ITGControls.ITGTextBox txtTruckerName 
               Height          =   285
               Left            =   -72165
               TabIndex        =   49
               TabStop         =   0   'False
               Top             =   390
               Width           =   4125
               _ExtentX        =   7170
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14737632
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               AllCaps         =   -1  'True
               Label           =   "ITGtext"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   0
               TextBoxWidth    =   4065
               Enabled         =   0   'False
            End
            Begin ITGControls.ITGTextBox txtTruckerCode 
               Height          =   285
               Left            =   -74805
               TabIndex        =   47
               Top             =   390
               Width           =   2280
               _ExtentX        =   3810
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               BackColor       =   14745599
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Mandatory       =   -1  'True
               Label           =   "Forwarder"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1000
               TextBoxWidth    =   1220
            End
            Begin ITGControls.ITGTextBox txtTruckerAdd 
               Height          =   285
               Left            =   -74805
               TabIndex        =   52
               Top             =   705
               Width           =   6765
               _ExtentX        =   11721
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Label           =   "Address"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1000
               TextBoxWidth    =   5705
               LinkForeColor   =   0
            End
            Begin ITGControls.ITGTextBox txtTruckerContact 
               Height          =   285
               Left            =   -74805
               TabIndex        =   54
               Top             =   1020
               Width           =   3075
               _ExtentX        =   5212
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Label           =   "Contact"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1000
               TextBoxWidth    =   2015
               LinkForeColor   =   0
            End
            Begin ITGControls.ITGTextBox txtTruckerTel 
               Height          =   285
               Left            =   -74805
               TabIndex        =   57
               Top             =   1335
               Width           =   3075
               _ExtentX        =   5212
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Label           =   "Telephone"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1000
               TextBoxWidth    =   2015
               LinkForeColor   =   0
            End
            Begin ITGControls.ITGTextBox txtTruckerFax 
               Height          =   285
               Left            =   -71370
               TabIndex        =   58
               Top             =   1335
               Width           =   3330
               _ExtentX        =   5662
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Label           =   "Fax No."
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1200
               TextBoxWidth    =   2070
               LinkForeColor   =   0
            End
            Begin ITGControls.ITGTextBox txtTruckerDest 
               Height          =   285
               Left            =   -67545
               TabIndex        =   50
               Top             =   390
               Width           =   2760
               _ExtentX        =   4657
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Label           =   "Destination"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1100
               TextBoxWidth    =   1600
               LinkForeColor   =   0
            End
            Begin ITGControls.ITGTextBox txtTruckerLine 
               Height          =   285
               Left            =   -67545
               TabIndex        =   53
               Top             =   705
               Width           =   3120
               _ExtentX        =   5292
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Label           =   "Shipping Line"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1100
               TextBoxWidth    =   1960
               LinkForeColor   =   0
            End
            Begin ITGControls.ITGDateBox dtbShipping 
               Height          =   285
               Left            =   -66420
               TabIndex        =   56
               Tag             =   "Order Date"
               Top             =   1020
               Width           =   1995
               _ExtentX        =   3519
               _ExtentY        =   503
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Text            =   ""
               SendKeysTab     =   -1  'True
               Mandatory       =   -1  'True
            End
            Begin ITGControls.ITGTextBox txtTruckerVessel 
               Height          =   285
               Left            =   -67545
               TabIndex        =   59
               Top             =   1335
               Width           =   3120
               _ExtentX        =   5292
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Label           =   "Vessel"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1100
               TextBoxWidth    =   1960
               LinkForeColor   =   0
            End
            Begin ITGControls.ITGTextBox txtTruckerType 
               Height          =   285
               Left            =   -71370
               TabIndex        =   55
               Top             =   1020
               Width           =   3330
               _ExtentX        =   5662
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Locked          =   -1  'True
               Label           =   "Type"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1200
               TextBoxWidth    =   2070
               Enabled         =   0   'False
               LinkForeColor   =   0
            End
            Begin VB.Label Label4 
               BackColor       =   &H00F7D9C2&
               Caption         =   "Expiration"
               Height          =   285
               Index           =   0
               Left            =   -67335
               TabIndex        =   79
               Top             =   1065
               Width           =   1305
            End
            Begin VB.Label Label5 
               BackColor       =   &H00F7D9C2&
               Caption         =   "Shipping Date"
               Height          =   225
               Left            =   -67515
               TabIndex        =   75
               Top             =   1080
               Width           =   1050
            End
            Begin VB.Label Label3 
               BackColor       =   &H00F7D9C2&
               Caption         =   "Payment Type"
               Height          =   285
               Left            =   7410
               TabIndex        =   71
               Top             =   1140
               Width           =   1305
            End
            Begin VB.Label Label2 
               BackColor       =   &H00F7D9C2&
               Caption         =   "Customer Terms"
               Height          =   285
               Left            =   7410
               TabIndex        =   70
               Top             =   825
               Width           =   1305
            End
            Begin VB.Label Label4 
               BackColor       =   &H00F7D9C2&
               Caption         =   "Internal Terms"
               Height          =   285
               Index           =   1
               Left            =   7410
               TabIndex        =   69
               Top             =   480
               Width           =   1305
            End
            Begin VB.Label Label1 
               BackColor       =   &H00F7D9C2&
               Caption         =   "Currency"
               Height          =   240
               Left            =   -67335
               TabIndex        =   68
               Top             =   390
               Width           =   1305
            End
         End
         Begin VB.Label ITGLabel4 
            BackColor       =   &H00F7D9C2&
            Caption         =   "Order Date"
            Height          =   255
            Left            =   4200
            TabIndex        =   74
            Top             =   495
            Width           =   1230
         End
      End
      Begin MSDataGridLib.DataGrid dtgList 
         Height          =   3510
         Left            =   -75000
         TabIndex        =   76
         Top             =   315
         Width           =   11550
         _ExtentX        =   20373
         _ExtentY        =   6191
         _Version        =   393216
         AllowUpdate     =   0   'False
         AllowArrows     =   -1  'True
         Appearance      =   0
         HeadLines       =   1
         RowHeight       =   15
         TabAction       =   2
         FormatLocked    =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   8
         BeginProperty Column00 
            DataField       =   "cSONo"
            Caption         =   "Sales Order No."
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "cCode"
            Caption         =   "Client ID"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "dDate"
            Caption         =   "Date"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   3
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "cType"
            Caption         =   "Type"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "cDelCode"
            Caption         =   "Delivery Client ID"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column05 
            DataField       =   "cSMan"
            Caption         =   "Salesman ID"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column06 
            DataField       =   "cCPONo"
            Caption         =   "Customer PO #"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column07 
            DataField       =   "cRemarks"
            Caption         =   "Remarks"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            AllowRowSizing  =   0   'False
            BeginProperty Column00 
               ColumnAllowSizing=   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   1349.858
            EndProperty
            BeginProperty Column01 
               Locked          =   -1  'True
               ColumnWidth     =   1275.024
            EndProperty
            BeginProperty Column02 
               Locked          =   -1  'True
               ColumnWidth     =   1049.953
            EndProperty
            BeginProperty Column03 
               Locked          =   -1  'True
               ColumnWidth     =   1065.26
            EndProperty
            BeginProperty Column04 
               Locked          =   -1  'True
               ColumnWidth     =   1395.213
            EndProperty
            BeginProperty Column05 
               Locked          =   -1  'True
               ColumnWidth     =   1110.047
            EndProperty
            BeginProperty Column06 
               Locked          =   -1  'True
               ColumnWidth     =   1335.118
            EndProperty
            BeginProperty Column07 
               Locked          =   -1  'True
               ColumnWidth     =   2220.094
            EndProperty
         EndProperty
      End
      Begin ITGControls.ITGTextBox txtNet 
         Height          =   285
         Left            =   8460
         TabIndex        =   24
         TabStop         =   0   'False
         Top             =   7530
         Width           =   2820
         _ExtentX        =   4763
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Total Amount"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1250
         TextBoxWidth    =   1510
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtDiscount 
         Height          =   285
         Left            =   8460
         TabIndex        =   23
         TabStop         =   0   'False
         Top             =   7215
         Width           =   2820
         _ExtentX        =   4763
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "Discount"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1250
         TextBoxWidth    =   1510
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtGross 
         Height          =   285
         Left            =   8460
         TabIndex        =   22
         TabStop         =   0   'False
         Top             =   6900
         Width           =   2820
         _ExtentX        =   4763
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Sub Total"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1250
         TextBoxWidth    =   1510
         LinkForeColor   =   0
      End
      Begin VB.CommandButton cmdServe 
         Caption         =   "&Served"
         Height          =   615
         Left            =   285
         Picture         =   "frmARSalesOrder.frx":1A06
         Style           =   1  'Graphical
         TabIndex        =   21
         TabStop         =   0   'False
         ToolTipText     =   "Serve Sales Order (Alt+S)"
         Top             =   6915
         Width           =   795
      End
      Begin VB.Label lblStatus 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Status"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   24
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C0C0C0&
         Height          =   855
         Left            =   3630
         TabIndex        =   62
         Top             =   6975
         Width           =   3495
      End
   End
End
Attribute VB_Name = "frmARSalesOrder"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

'IT Group Inc. 2005.09.23

Option Explicit

'Object variables




Private oPrint As New clsPrinting


'Recordset variables
Private WithEvents rsHeader As ADODB.Recordset
Attribute rsHeader.VB_VarHelpID = -1
Private rsDetail As ADODB.Recordset

Private rsAuto As ADODB.Recordset

'ADO Connection variables

Private connHeader As ADODB.Connection
Private connDetail As ADODB.Connection

'Form mode enumeration
Enum eSOMode
    Normal
    AddNewEdit
    Find
End Enum
Public Mode As eSOMode

'Other declarations
Private lLessAmount As Boolean
Private lLessPercent As Boolean
Private lNetOK As Boolean
Private net As Double

Public dtgName As String
Public sBit As String
Private vBM As Variant 'Recordset bookmark variable

Public lSystemGeneratedSO As Boolean
Private strNo As String
Private sAuto As String
Private sCustCode As String
Private sBarcodeID As String
'Auto Approval Variables
Public lAutoCL As Boolean
Public lAutoPrice As Boolean
Public lAutoStock As Boolean

Dim aQty(0 To 999) As Double

'Security Acess Level variables
Public lACNew As Boolean
Public lACEdit As Boolean
Public lACDelete As Boolean
Public lACPost As Boolean
Public lACCancel As Boolean
Public lACPrint As Boolean



Private Sub cboCurrency_Click()
    txtCurrency = Trim(cboCurrency)
    If Mode <> AddNewEdit Then Exit Sub
    txtCurrencyRate = GetValueFrTable("nRate", "CURRENCY", "cCurrency = '" & Trim(txtCurrency) & "'")
End Sub

Private Sub cboCurrency_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub cboIntTerms_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub cboPaymentType_Click()
    txtPaymentType = Trim(cboPaymentType)
End Sub

Private Sub cboPaymentType_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        SSTab2.ActiveTab = 1
    End If
    SendKeysTab KeyAscii
End Sub

Private Sub cboSO_Click()
On Error GoTo ErrorHandler
    If dtgSO.Col = 5 Then
        If Trim(cboSO) <> "" Then
            rsDetail!cPricing = cboSO
            '                If rsHeader!cType <> "Consignment" Then
            '                    GetRWMPrice
            '                Else
            '                    GetConPrice
            '                End If
                Select Case Trim(cboSO)
                    Case "SRP"
                        rsDetail!nPrice = IIf(GetValueFrTable("nSRPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'") = Null, 0, GetValueFrTable("nSRPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")) '* rsDetail!nFactor
                    Case "Regular"
                        rsDetail!nPrice = IIf(GetValueFrTable("nSRPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "' and cPartNo = '" & Trim(rsDetail!cBarcodeID) & "'") = Null, 0, GetValueFrTable("nSRPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")) '* rsDetail!nFactor
                    Case "WSP"
                        rsDetail!nPrice = IIf(GetValueFrTable("nWSPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "' and cPartNo = '" & Trim(rsDetail!cBarcodeID) & "'") = Null, 0, GetValueFrTable("nWSPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")) '* rsDetail!nFactor
                    Case "Wholesaler"
                        rsDetail!nPrice = IIf(GetValueFrTable("nWSPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "' and cPartNo = '" & Trim(rsDetail!cBarcodeID) & "'") = Null, 0, GetValueFrTable("nWSPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")) '* rsDetail!nFactor
                    Case "Pricing MS"
                        rsDetail!nPrice = 0
                    Case "Pricing Terms"
                        rsDetail!nPrice = 0
                    Case "Pricing Client"
                        rsDetail!nPrice = 0
                    Case "FOC"
                        rsDetail!nPrice = 0
                    Case "Others"
                        rsDetail!nPrice = 0
                    Case "Member"
                        GetCustFromPM
        '                Case "Consignee"
        '                    GetConPrice
                End Select
                rsDetail!cDiscount = ""
                rsDetail!nNetPrice = rsDetail!nPrice
                ComputeNet
                ComputeAmount
                ComputeTotal
        End If
    ElseIf dtgSO.Col = 10 Then
        rsDetail!cStatus = cboSO
    ElseIf dtgSO.Col = 14 Then
        rsDetail!cWH = cboSO
    ElseIf dtgSO.Col = 3 Then
        rsDetail!cUnit = cboSO
'        cboSO = rsDetail!cUnit
        rsDetail!nFactor = GetValueFrTable("nFactor", "ITEM_UNIT", "cItemNo= '" & Trim(rsDetail!cItemNo) & "' and cUnit = '" & rsDetail!cUnit & "'")
        rsDetail!nPrice = CDec(GetValueFrTable("nSRPrice", "ITEM", "cItemNo= '" & Trim(rsDetail!cItemNo) & "' ")) * rsDetail!nFactor
        If rsHeader!cType <> "Consignment" Then
            GetRWMPrice
        Else
'            GetConPrice
        End If
        dtgSO.Columns(8).Value = rsDetail!nPrice
        rsDetail!nQty = dtgSO.Columns(4).Value
        ComputeNet
        ComputeAmount
        ComputeTotal
    End If
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

Private Sub cboSO_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo ErrorHandler
    If KeyCode = 13 Then
        If dtgSO.Col = 5 Then
            rsDetail!cPricing = cboSO
            cboSO.Visible = False
            dtgSO.Col = 6
            dtgSO.SetFocus
        ElseIf dtgSO.Col = 10 Then
            
            If Trim(dtgSO.Columns(10).Text) = "Labor" Then Exit Sub
            Call LoadComboValues(cboSO, "cParamName", "PARAMETER_SYSTEM", "WHERE cType = 'PRODSTATUS'", "nOrder")
            Call MoveCombo(cboSO, dtgSO, dtgSO.Columns(10))
            ComboLoadValue cboSO, Trim(dtgSO.Columns(10).Text)
            
            cboSO.Visible = False
            dtgSO.Col = 11
            dtgSO.SetFocus
        ElseIf dtgSO.Col = 3 Then
            rsDetail!cUnit = cboSO
            cboSO.Visible = False
            dtgSO.Col = 4
            dtgSO.SetFocus
        End If
    ElseIf KeyCode = vbKeyEscape Then
        cboSO.Visible = False
    End If
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

Private Sub cboSO_LostFocus()
    If Me.ActiveControl.Name <> "cboSO" Then
        cboSO.Visible = False
    End If
End Sub

Private Sub cboTerms_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub cboType_Click()
If Mode <> AddNewEdit Then Exit Sub
    txtType = Trim(cboType)
    Do Until rsDetail.EOF
        GetChild
        rsDetail.Delete adAffectCurrent
        rsDetail.MoveNext
    Loop
End Sub

Private Sub cboIntTerms_Click()
    txtIntTerms = Trim(cboIntTerms)
End Sub

Private Sub cboTerms_Click()
    txtTerms = Trim(cboTerms)
End Sub

Private Sub cboType_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub cmdPickAddTo_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtAddTo)
    frmITGPicker.zType = QEmployee
    'added condition
    frmITGPicker.Condition = "where cCompanyID = '" & COID & "'"
    
    frmITGPicker.Show vbModal
    
    txtAddTo = frmITGPicker.zCode
    txtAddToName = frmITGPicker.zName
    If Trim(txtAddTo) <> "" Then SendKeys "{Tab}"
End Sub

'Call pick list module
Private Sub cmdPickCode_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtCode)
    With frmITGPicker
        
        Select Case UCase(Trim(cboType))
            Case "EMPLOYEE"
                .zType = QClientEmployee
            Case "CORPORATE"
                .zType = QClientSupplier
            Case Else
                .zType = QCustomer
        End Select
        .Condition = "where cCompanyID = '" & COID & "'"
        .Show vbModal
        txtCode = .zCode
        txtName = .zName
    End With

'    txtSMName = GetValueFrTable("(LastName + ', ' + FirstName + ' ' + MI) as Name", "SEC_USER", "UserID = '" & sUserName & "'", True)
End Sub

Private Sub cmdPickDCode_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtDCode)
    frmITGPicker.zType = QDistributor
    'added condition
    frmITGPicker.Condition = "AND cCompanyID = '" & COID & "'"
    
    frmITGPicker.Show vbModal
    txtDCode = frmITGPicker.zCode
    Me.txtDName = frmITGPicker.zName
    If Trim(txtDName) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub cmdPickDelCode_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtDelCode)
    With frmITGPicker
        .zType = QCustomer
        Select Case UCase(Trim(cboType))
            Case "Employee"
                .zType = QClientEmployee
            Case "CORPORATE"
                .zType = QClientSupplier
            Case Else
                .zType = QCustomer
        End Select
        'added condition
          frmITGPicker.Condition = "AND cCompanyID = '" & COID & "'"
          .Show vbModal
          txtDelCode = .zCode
          txtDelName = .zName
    End With
End Sub

Private Sub cmdPickDestination_Click()
    If lPickListActive Then Exit Sub
    frmITGPicker.zType = QLocation
    frmITGPicker.Show vbModal
    txtTruckerDest = frmITGPicker.zName
    If Trim(txtTruckerDest) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub cmdPickEmp_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtPromo)
    frmITGPicker.zType = QEmployee
    'added condition
    frmITGPicker.Condition = "where cCompanyID = '" & COID & "'"
    
    frmITGPicker.Show vbModal
    txtPromo = frmITGPicker.zCode
    txtPromoName = frmITGPicker.zName
    If Trim(txtPromo) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub cmdPickMS_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtMSCode)
    frmITGPicker.zType = QMarketSegment
    'added condition
    frmITGPicker.Condition = "AND cCompanyID = '" & COID & "'"
    
    frmITGPicker.Show vbModal
    txtMSCode = frmITGPicker.zCode
    txtMSDesc = frmITGPicker.zName
    If Trim(txtMSDesc) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub cmdPickPC_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtPCCode)
    frmITGPicker.zType = QProfitCenter
    'added condition
    frmITGPicker.Condition = "WHERE cCompanyID = '" & COID & "'"
    
    frmITGPicker.Show vbModal
    txtPCCode = frmITGPicker.zCode
    txtPCDesc = frmITGPicker.zName
    If Trim(txtPCDesc) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub cmdPickSM_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtSMCode)
    frmITGPicker.zType = QSalesman
    'added condition
    frmITGPicker.Condition = "where cCompanyID = '" & COID & "'"
    
    frmITGPicker.Show vbModal
    
    txtSMCode = frmITGPicker.zCode
    txtSMName = frmITGPicker.zName
    If Trim(txtSMName) <> "" Then SendKeys "{Tab}"
    
    


End Sub

Private Sub cmdPickTrucker_Click()
If lPickListActive Then Exit Sub
    sFilterString = Trim(txtTruckerCode)
    frmITGPicker.zType = QTRUCKER
    'added condition
    frmITGPicker.Condition = "AND cCompanyID = '" & COID & "'"
    
    frmITGPicker.Show vbModal
    txtTruckerCode = frmITGPicker.zCode
    txtTruckerName = frmITGPicker.zName
    If Trim(txtTruckerName) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub cmdServe_Click()
On Error GoTo ErrorHandler
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lServed = True Then
        MsgBox "Transaction was already served.", vbExclamation, "ComUnion"
        Exit Sub
    ElseIf rsHeader!lCancelled = True Then
        MsgBox "Cancelled transaction cannot be served.", vbExclamation, "ComUnion"
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to serve this record?", vbQuestion + vbYesNo, "ComUnion") = vbNo Then Exit Sub

    'Audit trail
    UpdateLogFile "Sales Order", Trim(txtSONo), "Served"

    rsHeader!lServed = True
    rsHeader.UpdateBatch adAffectAll
    
    cn.Execute ("UPDATE SO SET lServed = 1 WHERE cSONo = '" & Trim(txtSONo) & "' AND cCompanyID = '" & COID & "'")

    sbRS.Panels(5) = "SERVED"
    lblStatus.Caption = "Served"
    lblStatus.ForeColor = &HC0C0C0
    Mode = Normal
    
ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

Private Sub dtgList_HeadClick(ByVal ColIndex As Integer)
    SortGrid dtgList, ColIndex, rsHeader
End Sub

'After column update
Private Sub dtgSO_AfterColUpdate(ByVal ColIndex As Integer)
On Error GoTo ErrorHandler
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
'        dtgSO.Columns(ColIndex).lo
'        rsDetail.Index
        Case 1
            If GetValueFrTable("cItemNo", "ITEM", "cItemNo = '" & Trim(dtgSO.Columns(1).Value) & "'") <> "" Then
                GetInitialItemValues
                dtgSO_ButtonClick 2
                dtgSO.Col = 3
                dtgSO.Columns(3).Value = rsDetail!cUnit
            Else
                If lPickListActive Then Exit Sub
                sFilterString = Trim(dtgSO.Columns(1).Text)
                frmITGPicker.zType = QProduct
                frmITGPicker.Show vbModal
                rsDetail!cBarcodeID = Trim(frmITGPicker.zCode) & ""
                rsDetail!cItemNo = GetValueFrTable("cItemNo", "ITEM", "cPartNo = ' " & Trim(frmITGPicker.zCode) & "'")
                
                If (Trim(frmITGPicker.zName) & "") <> "" Then
                    dtgSO.Col = 3
                    GetInitialItemValues
'                    If rsHeader!cType <> "Consignment" And rsHeader!cType <> "For Sales-Con" Then
'                        rsDetail!cPricing = GetValueFrTable("cCustomerType", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'", True)
'                        GetRWMPrice
'                    Else
''                        rsDetail!cPricing = "Regular"
'                        GetConPrice
'                    End If
'
                    dtgSO.Columns(3).Value = rsDetail!cUnit
                End If
            End If
        Case 4
'            If dtgSO.Columns(10).Text = "Labor" Then GoTo forLabor
'            If dtgSO.Columns(4).Value > aQty(rsDetail.AbsolutePosition) Then
'                rsDetail!cStatus = "No Stock"
'            ElseIf dtgSO.Columns(4).Value = 0 Then
'                rsDetail!cStatus = "No Stock"
'            Else
'                rsDetail!cStatus = "Available"
'            End If
forLabor:
            ComputeNet
            ComputeAmount
            ComputeTotal
        Case 5
            ComputeAmount
            ComputeTotal
        Case 6
            ComputeNet
            If Not lNetOK Then Exit Sub
            ComputeAmount
            ComputeTotal
        Case 7
            If Right(Trim(dtgSO.Columns(7).Text), 1) = "-" Then
                dtgSO.Columns(7).Text = Mid(Trim(dtgSO.Columns(7).Text), 1, Len(Trim(dtgSO.Columns(7).Text)) - 1)
                lLessAmount = False
            End If
            
            ComputeNet
            If Not lNetOK Then Exit Sub
            ComputeAmount
            ComputeTotal
    End Select
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

Private Sub dtgSO_ButtonClick(ByVal ColIndex As Integer)
On Error GoTo ErrorHandler
If ColIndex = 2 Then
    If Mode <> Find Then
        Call MoveText(txtLongDesc, dtgSO, dtgSO.Columns(2))
        txtLongDesc = rsDetail!cLongDesc & ""
    End If
End If
If Mode = AddNewEdit Then 'Exit Sub
    Select Case ColIndex
        Case 1
            If GetValueFrTable("cItemNo", "ITEM", "cItemNo = '" & Trim(dtgSO.Columns(1).Value) & "'") = "" Then
                If lPickListActive Then Exit Sub
                sFilterString = Trim(dtgSO.Columns(1).Text)
                frmITGPicker.zType = QProduct
                frmITGPicker.Condition = "where cCompanyID = '" & COID & "'"
                frmITGPicker.Show vbModal
                If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'ITM_MAN_BARCODE'") = True Then
                    rsDetail!cBarcodeID = Trim(frmITGPicker.zPart) & ""
                End If
                rsDetail!cItemNo = Trim(frmITGPicker.zCode) & "" 'GetValueFrTable("cItemNo", "ITEM", "cPartNo = ' " & Trim(frmITGPicker.zCode) & "'")
                If GetCustomerCode = True Then rsDetail!cCustCode = sCustCode
                rsDetail!cLongDesc = "Color: " & GetValueFrTable("cGroup1", "ITEM", "cItemNo = '" & rsDetail!cItemNo & "'", True)
                If (Trim(frmITGPicker.zName) & "") <> "" Then
                    dtgSO.Col = 3
                    GetInitialItemValues
'                    If rsHeader!cType <> "Consignment" And rsHeader!cType <> "For Sales-Con" Then
'                        rsDetail!cPricing = GetValueFrTable("cCustomerType", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'", True)
'                        GetRWMPrice
'                    Else
''                        rsDetail!cPricing = "Regular"
'                        GetConPrice
'                    End If
                    
                    dtgSO.Columns(3).Value = rsDetail!cUnit
                End If
                
                'mon
                If GetValueFrTable("cType", "ITEM", "cItemNo = '" & Trim(dtgSO.Columns(1).Value) & "'") = "Labor" Then
                dtgSO.Columns(10).Value = "Labor"
                End If
'                dtgSO_ButtonClick 14

'                frmMaintProduct.Show
'                frmMaintProduct.ZOrder
'                frmMaintProduct.ShowForm LTrim(RTrim(dtgSO.Columns(1).Text))
            End If
            
        Case 3
            If dtgSO.Columns(1).Text <> "" Then
                If GetValueFrTable("cUnit", "ITEM_UNIT", "cItemNo = '" & Trim(dtgSO.Columns(1).Text) & "'") <> "" Then
                    Call LoadComboValues(cboSO, "cUnit", "ITEM_UNIT", "cItemNo = '" & Trim(dtgSO.Columns(1).Text) & "'")
                Else
                    Call LoadComboValues(cboSO, "cParamName", "PARAMETER_USER", "WHERE cType = 'ITEMUNIT'")
                End If
                    Call MoveCombo(cboSO, dtgSO, dtgSO.Columns(3))
                    ComboLoadValue cboSO, Trim(dtgSO.Columns(3).Text)
            End If
            dtgSO.Col = 3
        Case 5
'            If GetValueFrTable("cCustomerType", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'", True) <> "Consignee" Then
                Call LoadComboValues(cboSO, "cValue", "PARAMETER_SYSTEM", "WHERE cType = 'PRICING'", "nOrder")
                Call MoveCombo(cboSO, dtgSO, dtgSO.Columns(5))
                ComboLoadValue cboSO, Trim(dtgSO.Columns(5).Text)
                dtgSO.Col = 5
'            Else
'                cboSO.Clear
'                cboSO.AddItem "Regular"
'                cboSO.AddItem "Promo"
'                cboSO = "Regular"
'                Call MoveCombo(cboSO, dtgSO, dtgSO.Columns(5))
'                ComboLoadValue cboSO, Trim(dtgSO.Columns(5).Text)
'            End If
        Case 6
            frmITGPickList.mParam = Trim(dtgSO.Columns(5).Text)
            If dtgSO.Columns(5).Value = "SRP" Then
                If lPickListActive Then Exit Sub
                sClient = Trim(txtCode.Text)
                frmITGPickList.mType = SRP
                cString = Trim(rsDetail!cItemNo)
                frmITGPickList.Show vbModal
                If Trim(frmITGPickList.mCode) <> "" Then
                    dtgSO.Columns(6).Value = CDbl(frmITGPickList.mCode)
                End If
                ComputeNet
                If Not lNetOK Then Exit Sub
                ComputeAmount
                ComputeTotal
            ElseIf dtgSO.Columns(5).Value = "Pricing MS" Then
                If lPickListActive Then Exit Sub
                RepName = Trim(txtMSCode.Text)
                frmITGPickList.mType = SRP
                cString = Trim(rsDetail!cItemNo)
                frmITGPickList.mUnit = Trim(rsDetail!cUnit)
                frmITGPickList.Show vbModal
                If Trim(frmITGPickList.mCode) <> "" Then
                    dtgSO.Columns(6).Value = CDbl(frmITGPickList.mCode)
                End If
                If Trim(frmITGPickList.mCode) <> "" Then
                    dtgSO.Columns(7).Value = (frmITGPickList.mDisc)
                End If
                SendKeys "{Tab}"
                ComputeNet
                If Not lNetOK Then Exit Sub
                ComputeAmount
                ComputeTotal
            ElseIf dtgSO.Columns(5).Value = "Pricing Client" Then
                If lPickListActive Then Exit Sub
                
                If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'CLNT_MAN_USEPARENTCOMPANY'") = False Then
                    sClient = Trim(txtCode.Text)
                Else
                    sClient = GetValueFrTable("cGroupCode", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtCode.Text) & "'", True)
                End If
                If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'ITM_MAN_BARCODE'") = True Then
                    cPartFilter = " And cPartNo = '" & Trim(rsDetail!cBarcodeID) & "'"
                Else
                    cPartFilter = ""
                End If
                frmITGPickList.mType = SRP
                If GetValueFrTable("cGroupCode", "client_customer", "cCode = '" & rsHeader!cCode & "'") = "" Then
                    sClient = Trim(txtCode)
                Else
                    sClient = GetValueFrTable("cGroupCode", "client_customer", "cCode = '" & rsHeader!cCode & "'")
                End If
                cString = Trim(rsDetail!cItemNo)
                frmITGPickList.mUnit = Trim(rsDetail!cUnit)
                frmITGPickList.Show vbModal
                If Trim(frmITGPickList.mCode) <> "" Then
                    dtgSO.Columns(6).Value = CDbl(frmITGPickList.mCode)
                End If
                If Trim(frmITGPickList.mCode) <> "" Then
                    If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'ITM_MAN_BARCODE'") = False Then
                        dtgSO.Columns(7).Value = (frmITGPickList.mDisc)
                    Else
                        dtgSO.Columns(17).Value = (frmITGPickList.mDisc)
                    End If
                End If
                GetCommission
                SendKeys "{Tab}"
                ComputeNet
                If Not lNetOK Then Exit Sub
                ComputeAmount
                ComputeTotal
            ElseIf dtgSO.Columns(5).Value = "Pricing Terms" Then
                If lPickListActive Then Exit Sub
                RepName = Trim(txtTerms.Text)
                frmITGPickList.mType = SRP
                frmITGPickList.mUnit = Trim(rsDetail!cUnit)
                cString = Trim(rsDetail!cItemNo)
                frmITGPickList.Show vbModal
                If Trim(frmITGPickList.mCode) <> "" Then
                    dtgSO.Columns(6).Value = CDbl(frmITGPickList.mCode)
                End If
                If Trim(frmITGPickList.mCode) <> "" Then
                    dtgSO.Columns(7).Value = (frmITGPickList.mDisc)
                End If
                SendKeys "{Tab}"
                ComputeNet
                If Not lNetOK Then Exit Sub
                ComputeAmount
                ComputeTotal
            End If
        Case 10
            If Trim(dtgSO.Columns(10).Text) = "Labor" Then Exit Sub
            Call LoadComboValues(cboSO, "cParamName", "PARAMETER_SYSTEM", "WHERE cType = 'PRODSTATUS'", "nOrder")
            Call MoveCombo(cboSO, dtgSO, dtgSO.Columns(10))
            ComboLoadValue cboSO, Trim(dtgSO.Columns(10).Text)
        Case 14
            Call LoadComboValues(cboSO, "cWH", "WHSE", "WHERE cCompanyID = '" & COID & "'")
            Call MoveCombo(cboSO, dtgSO, dtgSO.Columns(14))
            ComboLoadValue cboSO, Trim(dtgSO.Columns(14).Text)
            If lPickListActive Then Exit Sub
            sFilterString = Trim(dtgSO.Columns(14).Text)
            frmITGPicker.zType = QBarcode
            If GetValueFrTable("cCustomerType", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cDelCode & "'") = "Consignee" Then
                frmITGPicker.Condition = "AND cRefID = '" & Trim(txtCode) & "' and cItemNo = '" & rsDetail!cItemNo & "'"
            Else
                frmITGPicker.Condition = " AND cType <> 'Consignee'  and cItemNo = '" & rsDetail!cItemNo & "'"
            End If
            frmITGPicker.Show vbModal
            rsDetail!cBarcodeID = Trim(frmITGPicker.zCode) & ""
            rsDetail!nPrice = GetValueFrTable("nPrice", "ITEM_UNIT", "cItemNo = '" & rsDetail!cItemNo & "' and cBarcode = '" & Trim(frmITGPicker.zCode) & "'")
            rsDetail!cPricing = GetValueFrTable("cCustomerType", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cDelCode & "'")
            rsDetail!nNetPrice = rsDetail!nPrice
            frmITGPicker.Condition = ""
            GetConPrice
            ComputeAmount
            ComputeTotal
    End Select
Else
    Select Case ColIndex
        Case 1
            If Mode <> Find Then
                If Trim(dtgSO.Columns(1).Text) <> "" Then
'                    frmMaintProduct.Show
'                    frmMaintProduct.ZOrder
'                    frmMaintProduct.ShowForm LTrim(RTrim(dtgSO.Columns(1).Text))
                End If
            End If
    End Select
End If
ErrorHandler:
    If err.Number <> 0 And err.Number <> -2147217908 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

Private Sub dtgSO_Click()
    If Mode = AddNewEdit Then dtgName = dtgSO.Name
End Sub

Private Sub dtgSO_Error(ByVal DataError As Integer, Response As Integer)
    Response = 0
End Sub

Private Sub dtgSO_KeyDown(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If (Shift = vbCtrlMask And KeyCode = 45) Then
        TBNewLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 46) Then
        TBDeleteLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 83) Then
        TBSave
    End If
End Sub


Private Sub dtgSO_KeyPress(KeyAscii As Integer)
On Error GoTo ErrorHandler
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then Exit Sub
        
    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    
    If KeyAscii = 13 Then
        Select Case dtgSO.Col
            Case 1
                If cboSO.Visible = False Then
                    dtgSO_ButtonClick (1)
                Else
                    SendKeys "{Tab}"
                End If
            Case 3
                If cboSO.Visible = False Then
                    dtgSO_ButtonClick (3)
                Else
                    SendKeys "{Tab}"
                End If
            Case 4   ' Quantity
                ComputeNet
                ComputeAmount
                ComputeTotal
                SendKeys "{Tab}"
            Case 5
                If cboSO.Visible = False Then
                    dtgSO_ButtonClick (5)
                    If Trim(dtgSO.Columns(5).Text) <> "" Then cboSO = Trim(dtgSO.Columns(5).Text)
                Else
                    SendKeys "{Tab}"
                End If
            Case 7
                rsDetail!cDiscount = dtgSO.Columns(7).Text
                dtgSO_AfterColUpdate (7)
                dtgSO.Col = 10

                If Not lNetOK Then
                    dtgSO.Col = 7
                    dtgSO.Columns(7).Value = rsDetail!cDiscount
                    Exit Sub
                End If
            Case 10
                If cboSO.Visible = False Then
                    dtgSO_ButtonClick (10)
                    If Trim(dtgSO.Columns(10).Text) <> "" Then cboSO = Trim(dtgSO.Columns(10).Text)
                Else
                    SendKeys "{Tab}"
                End If
'            Case 11
'                If cboSO.Visible = False Then
'                    dtgSO_ButtonClick (11)
'                    If Trim(dtgSO.Columns(11).Text) <> "" Then cboSO = Trim(dtgSO.Columns(11).Text)
'                Else
'                    SendKeys "{Tab}"
'                End If
'            Case 12
'                TBNewLine
'                dtgSO.LeftCol = 1
            Case 11
                TBNewLine
                dtgSO.LeftCol = 1
            Case Else
                SendKeys "{Tab}"
        End Select
    Else
        Select Case dtgSO.Col
            Case 7
'                '"-" character
'                If (KeyAscii = 45) And lLessAmount Then
'                    KeyAscii = 0
'                ElseIf KeyAscii = 45 Then
'                    lLessAmount = True
'                End If
'
'                '"/" character
'                If (KeyAscii = 47) And lLessPercent Then
'                    KeyAscii = 0
'                ElseIf KeyAscii = 47 Then
'                    lLessPercent = True
'                    lLessAmount = False
'                Else
'                    lLessPercent = False
'                End If
               
                KeyAscii = ValidKeys(KeyAscii, "-/1234567890.", True)
            Case Else
                KeyAscii = Asc(UCase(Chr(KeyAscii))) 'All Upper Case String
        End Select
    End If
    
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

Private Sub dtgSO_KeyUp(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then Exit Sub
    Select Case dtgSO.Col
        Case 7
            If Trim(dtgSO.Columns(7).Text) = "/" Then
                dtgSO.Columns(7).Text = ""
                lLessPercent = False
            End If
    End Select
End Sub

'Right click menu popup
Private Sub dtgSO_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Mode <> AddNewEdit Then Exit Sub
    If Button = 2 Then
        dtgName = dtgSO.Name
        PopupMenu ITGLedgerMain.mnuDetail
    End If
End Sub


' Code by gino do not erase
' To visible the combobox of the grid
'when click the scroll of the grid

Private Sub dtgSO_Scroll(Cancel As Integer)
    cboSO.Visible = False
End Sub
'---------------------------------------


Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Dim iKey As Integer
    iKey = ToolbarIndex(KeyCode, Shift)
    If iKey <> 0 Then
        If ITGLedgerMain.tbrMain.Buttons(iKey).Enabled = True Then
            ToolbarFunction iKey
        End If
    End If
End Sub

'Set Your Object
Private Sub Form_Load()
    
    Set FrmName = Me
    FormSetup
    
    AcessBit Me, GetValueFrTable("AccessLevel", "SEC_ACCESSLEVEL", "RoleID = '" & SecUserRole & "' AND [Module] = 'OD01'")
    
    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset
    
    
    'Load combobox values
    Call LoadComboValues(cboTerms, "cParamName", "PARAMETER_USER", "WHERE cType = 'TERMS' AND cCompanyID = '" & Trim(COID) & "'", "nOrder")
    Call LoadComboValues(cboIntTerms, "cParamName", "PARAMETER_USER", "WHERE cType = 'TERMS' AND cCompanyID = '" & Trim(COID) & "'", "nOrder")
    Call LoadComboValues(cboPaymentType, "cValue", "PARAMETER_SYSTEM", "WHERE cType = 'SOPAYTYPE'")
    Call LoadComboValues(cboCurrency, "cCurrency", "CURRENCY", "WHERE cCompanyID = '" & Trim(COID) & "'")
    
    Call ColumnVisible("Internal Barcode ID", dtgSO)
    Call ColumnVisible("Customer Code", dtgSO)
    Call ColumnVisible("Barcode/SKU", dtgSO)
    
    FormLocking True
    FormSearch True
    SearchObj True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True

    Mode = Find
    txtSONo.Locked = False
    
    lNetOK = True 'Boolean variable for discount computation
    
    'System generated so number
    'lSystemGeneratedSO = GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'OTHERS_AUTOTRANNO_SO' ")
    
    'Auto Approval Variables
    lAutoCL = GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'AUTOAPPROVE_CL' ")
    lAutoPrice = GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'AUTOAPPROVE_PRICE' ")
    lAutoStock = GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'AUTOAPPROVE_STOCK' ")
        
    dtgSO.Columns(15).Visible = GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'ITM_MAN_BARCODE'")
    dtgSO.Columns(17).Visible = GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'ITM_MAN_BARCODE'")
    dtgSO.Columns(16).Visible = GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'ITM_MAN_USECUSTITEMNO'")

    SetVisibleEnable
End Sub

'Activate your Toolbar Mode
Private Sub Form_Activate()
    TBBitReload
End Sub

'Release your Object
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
    If Mode = AddNewEdit Then
        MsgBox "Unable to close. You are in Add/New/Edit mode." & vbCr & _
            " Must Save or Undo", vbCritical, Me.Caption
        Cancel = True
        Exit Sub
    End If
    
    CloseMenuTab ITGLedgerMain
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , , , , , True
    BitVisible ITGLedgerMain.tbrMain
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = False
    
    Set oPrint = Nothing
    
    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set rsAuto = Nothing
    Set connHeader = Nothing
    Set connDetail = Nothing
    
    Set frmARSalesOrder = Nothing

    lCloseWindow = True
    
End Sub

'Add new record to the recordset
Public Sub TBNew()
On Error GoTo ErrorHandler
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    txtSONo.BackColor = &HE0FFFF
    Mode = AddNewEdit
    
    If rsHeader.State <> adStateOpen Then
        OpenNewConnection connHeader
        OpenNewConnection connDetail
        OpenRecordsetWithCN rsDetail, "*", "SO_T", connDetail, "WHERE 1 = 0"
        OpenRecordsetWithCN rsHeader, "*", "SO", connHeader, "WHERE 1 = 0"
        SetDataSource
        SetDataField
    Else
        vBM = rsHeader.Bookmark
    End If
    
    rsHeader.AddNew
    rsHeader!cCompanyID = COID
    rsHeader!dDate = Date
    rsHeader!cType = "" 'for purpose of txttype_change to get control number
    rsHeader!cType = "Regular"
    rsHeader!cPayType = "Credit"
    rsHeader!cCurrency = "PHP"
    rsHeader!nCurrencyRate = Format(GetValueFrTable("nRate", "CURRENCY", "cCurrency = 'PHP'"), "#,##0.#0")
    rsHeader!cPreparedBy = SecUserID
    rsHeader!cPCCode = sDivision
    
    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    txtGross.Locked = True
    SSTab2.ActiveTab = 0
    txtNet.Locked = True
    txtDCode.Locked = True
    cmdPickDCode.Enabled = False
    SSTab1.ActiveTab = 0
    'not system generated so no
    txtSONo.Locked = False
    '--------------------------
    txtSONo.SetFocus

    'system generated so no
    'If lSystemGeneratedSO Then GetCtrlNo
    '--------------------------
ErrorHandler:
    If err.Number <> 0 And err.Number <> 3021 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

'Undo all changes to the recordset
Public Sub TBUndoAll()
On Error GoTo ErrorHandler

    Mode = Normal
    
    If rsHeader.Status = adRecNew Then TBUndoCurrent
    
    rsHeader.CancelBatch adAffectAll
    rsDetail.CancelBatch adAffectAll
    
    UnbindControls
    
    If rsHeader.RecordCount <> 0 Then rsHeader.Bookmark = vBM
    
    Set FrmName = Me
    FormLocking True
    
    If rsHeader.RecordCount <> 0 Then
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True, , True
        'cmdLinkCustomer.Enabled = True
    Else
        RSZero
        Mode = Find
        
    End If
    
    SSTab1.TabEnabled(1) = True
    
    sbRS.Panels(2) = ""

    SetDataSource
    SetDataField

ErrorHandler:
    cboSO.Visible = False
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoAll
    End If
End Sub

'Undo changes on the current record
Public Sub TBUndoCurrent()
On Error GoTo ErrorHandler

    GetChild
    If rsHeader.Status = adRecNew Then
        rsDetail.CancelBatch adAffectAll
        rsHeader.CancelUpdate
    Else
        rsHeader.CancelBatch adAffectCurrent
        rsDetail.CancelBatch adAffectAll
    End If
   
    If rsHeader.RecordCount = 0 Then RSZero

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoCurrent
    End If

End Sub

'Save all changes
Public Sub TBSave()
Dim OKUpdate As Boolean
Dim lNew As Boolean
On Error GoTo ErrHandler

    'Audit Trail
    lBoolean = False
    If rsHeader.Status = adRecNew Then
        lBoolean = True
        rsHeader!dPrepared = Now
    End If
    
    If Not MandatoryOK Then Exit Sub
    
    'Discount validation
    ComputeNet
    If Not lNetOK Then
        dtgSO.SetFocus
        Exit Sub
    End If
    ComputeAmount
    ComputeTotal
   
    'System generated so no
    If rsHeader.Status = adRecNew Then
        
        If lSystemGeneratedSO = True Then
            If Not CheckCtrlNo Then Exit Sub
        End If
        lNew = True
    End If
    '----------------------
    If rsHeader!cType = "Consignment" Or rsHeader!cType = "For Sales-Con" Then
        rsHeader!lCApproved = 1
        rsHeader!lPApproved = 1
    Else
        rsHeader!lCApproved = lAutoCL
        rsHeader!lPApproved = lAutoPrice
    End If
'    rsHeader!lCApproved = lAutoCL
'    rsHeader!lPApproved = lAutoPrice
    
    OKUpdate = False
    cn.BeginTrans
    connHeader.BeginTrans
    connDetail.BeginTrans
    
    rsHeader.UpdateBatch adAffectAll
    rsDetail.UpdateBatch adAffectAll
    
    If (UCase(Trim(cboType)) = "FOR SALES-CON") Then
        If Not SOToDR Then GoTo ErrHandler
    End If
    
    cn.CommitTrans
    connDetail.CommitTrans
    connHeader.CommitTrans
    OKUpdate = True
    
    Set FrmName = Me
    FormLocking True
    'cmdLinkCustomer.Enabled = True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True, , True
    Mode = Normal
    
    MsgBox "Record/s successfully saved.", vbInformation, "ComUnion"
    sbRS.Panels(2) = ""
    SSTab2.ActiveTab = 0
    'Audit trail
    UpdateLogFile "Sales Order", Trim(txtSONo), IIf(lBoolean, "Inserted", "Updated")
    
    'System generated so no
    If lNew = True Then
        If lSystemGeneratedSO = True Then UpdateCtrlNo
    End If
    '----------------------

ErrHandler:
    cboSO.Visible = False
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        OKUpdate = True
        cn.RollbackTrans
        connDetail.RollbackTrans
        connHeader.RollbackTrans
        MsgBox "Record cannot be updated. Some values may have been changed by other user/s since last read." & vbCr & _
                "Records will be automatically refreshed. All changes made to the record will be gone upon refresh.", vbInformation, "ComUnion"
        vBookMark = rsHeader.Bookmark
        UnbindControls
        rsHeader.Requery
        rsDetail.Requery
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True
        Mode = Normal
        If rsHeader.RecordCount <> 0 Then
            Set FrmName = Me
            FormLocking True
            'cmdLinkCustomer.Enabled = True
            SetDataField
            SetDataSource
            rsHeader.Bookmark = vBookMark
        Else
            RSZero
        End If
    End If
    If Not OKUpdate Then
        MsgBox "Transaction update failed.", vbInformation, "ComUnion"
        cn.RollbackTrans
        connDetail.RollbackTrans
        connHeader.RollbackTrans
        ErrorLog err.Number, err.Description, Me.Name 'Error log
    End If
    
End Sub

'Sets the form & recorset to add/edit mode
Public Sub TBEdit()
On Error GoTo ErrorHandler
    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Edit is not allowed.", vbExclamation, "ComUnion"
        Exit Sub
    ElseIf rsHeader!lServed = True Then
        MsgBox "Transaction was already served. Deletion is not allowed.", vbExclamation, "ComUnion"
        Exit Sub
    End If
    If Not AllowEdit Then Exit Sub
    Mode = AddNewEdit
    'Timer functionalities
    SSTab1.TabEnabled(1) = False
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    txtGross.Locked = True
    txtNet.Locked = True
    SSTab1.ActiveTab = 0
    dtbDate.SetFocus
    vBM = rsHeader.Bookmark
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

'Delete record
Public Sub TBDelete()
On Error GoTo ErrorHandler
    
    sID = Trim(txtSONo)
    
    If rsHeader.RecordCount = 0 Then Exit Sub
    
    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Deletion is not allowed.", vbExclamation, "ComUnion"
        Exit Sub
    ElseIf rsHeader!lServed = True Then
        MsgBox "Transaction was already served. Deletion is not allowed.", vbExclamation, "ComUnion"
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to delete this record?", vbQuestion + vbYesNo, "ComUnion") = vbNo Then Exit Sub
    
    If Not AllowDelete("delete") Then Exit Sub
        
    GetChild
    If rsDetail.RecordCount <> 0 Then
        rsDetail.MoveFirst
        Do Until rsDetail.RecordCount = 0
            rsDetail.Delete adAffectCurrent
            If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
        Loop
    End If
    
    'Audit trail
    UpdateLogFile "Sales Order", Trim(txtSONo), "Deleted"

    rsHeader.Delete adAffectCurrent
    
    rsDetail.UpdateBatch adAffectAll
    rsHeader.UpdateBatch adAffectAll
    
    TBPrevRec

    Mode = Normal
    
    If rsHeader.RecordCount = 0 Then
        RSZero
    End If

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        cn.Execute "DELETE SO_T WHERE cSONo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        cn.Execute "DELETE SO WHERE cSONo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        Resume Next
    End If

End Sub

'Search using the frmITGSearch
Public Sub TBFind()
    Mode = Normal
    txtSONo.Locked = True
    frmITGSearch.Show 'vbModal
End Sub

'Search using the recordset primary key
Public Sub TBFindPrimary()
On Error GoTo ErrorHandler
Dim sTemp As String
If Mode = Find Then
    FormWaitShow App.Path & "\Transmit.avi", "Loading data . . ."
        
    OpenNewConnection connHeader
    OpenNewConnection connDetail
    
    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset
            
    sTemp = Trim$(GetSearchString)
    If sTemp = "ERROR" Then
        MsgBox "Only Allows A - Z, 0 - 9, '.', ',' and %(wildcard)", vbExclamation, ""
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
        txtSONo.Locked = False
        txtSONo.SetFocus
        Exit Sub
    End If
    
    OpenRecordsetWithCN rsHeader, "*", "SO", connHeader, IIf(sTemp = "", "where cType <> 'EXPORT' ", " WHERE cType <> 'EXPORT' and " & sTemp)
    'OpenRecordsetWithCN rsDetail, "*", "SO_T", connDetail
                      
    OpenRecordsetWithCN rsDetail, "*", "SO_T", connDetail, IIf(sTemp = "", "", " WHERE cSONo IN (SELECT cSONo FROM SO WHERE " & sTemp & ")")
       
    Set FrmName = Me
    FormLocking True
            
    If rsHeader.RecordCount = 0 Then
        FormWaitHide
        MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
        cboType.ListIndex = -1
        RSZero
        FormSearch True
        SearchObj True
        Mode = Find
        Exit Sub
    End If
    SetDataSource
    SetDataField
    txtSONo.BackColor = &HE0FFFF
    Mode = Normal
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True, , True

    FormWaitHide
Else
    RSZero
    FormSearch True
    SearchObj True
    Mode = Find
    
    
End If
    SSTab1.TabEnabled(1) = True
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

'Reload menu buttons (do not delete this sub)
Public Sub TBBitReload()
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
    BitReload ITGLedgerMain, Me, ITGLedgerMain.tbrMain, sBit
    Set FrmName = Me
    dtgName = dtgSO.Name
End Sub

'Close active window
Public Sub TBCloseWindow()
    Unload Me
End Sub

'Move first
Public Sub TBFirstRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveFirst rsHeader
    
End Sub

'Move previuos
Public Sub TBPrevRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MovePrevious rsHeader
    
End Sub

'Move next
Public Sub TBNextRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveNext rsHeader
    
End Sub

'Move last
Public Sub TBLastRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveLast rsHeader
    
End Sub

'Add new line to the detail recordset
Public Sub TBNewLine()
On Error GoTo ErrorHandler
    If rsHeader!cSONO = "" Then Exit Sub
    If Trim(rsHeader!cPCCode) = "" Then
        'MsgBox "Profit Center is required before item selection.", vbInformation, "ComUnion"
        'SSTab2.Tab = 1
        'txtPCCode.SetFocus
        'Exit Sub
    End If
    
    If dtgName = "dtgSO" Then
        rsDetail.AddNew
        rsDetail!cCompanyID = COID
        rsDetail!cSONO = Trim(rsHeader!cSONO)
        rsDetail!lDRReady = lAutoStock
        rsDetail!cWH = "MAIN"
        dtgSO.Col = 0
        GetChild
        If rsDetail.RecordCount <> 0 Then rsDetail.MoveLast
        dtgSO.Col = 0
        dtgSO.Columns(1).Value = ""
        dtgSO.SetFocus
    End If
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

'Delete line in the detail recordset
Public Sub TBDeleteLine()
On Error GoTo ErrorHandler
    
    If dtgName = "dtgSO" Then
        If rsDetail.RecordCount = 0 Then Exit Sub
        vBookMark = dtgSO.Bookmark
        GetChild
        dtgSO.Bookmark = vBookMark
        rsDetail.Delete adAffectCurrent
        ComputeTotal
    End If
    GetChild
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    
ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo All
Public Sub TBUndoLineAll()
On Error GoTo ErrorHandler

    If dtgName = "dtgSO" Then
        rsDetail.CancelBatch adAffectAll
    End If

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo current line
Public Sub TBUndoLineCurrent()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Post current record
Public Sub TBPostRecord()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Cancel current record
Public Sub TBCancelRecord()
On Error GoTo ErrorHandler
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled.", vbExclamation, "ComUnion"
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to cancel this record?", vbQuestion + vbYesNo, "ComUnion") = vbNo Then Exit Sub

    If Not AllowDelete("cancel") Then Exit Sub
    
    cString = ""
    frmRemarks.fraRemarks.Caption = "Sales order cancellation remarks"
    frmRemarks.Show vbModal
    rsHeader!cCRemarks = cString
    
    'Audit trail
    UpdateLogFile "Sales Order", Trim(txtSONo), "Cancelled"

    cn.Execute ("UPDATE SO SET lCancelled = 1 WHERE cSONo = '" & Trim(txtSONo) & "' AND cCompanyID = '" & COID & "'")
    
    sbRS.Panels(5) = "CANCELLED"
    lblStatus.Caption = "Cancelled"
    lblStatus.ForeColor = &H8080FF
    Mode = Normal
    
    rsHeader!lCancelled = True
    rsHeader.UpdateBatch adAffectAll

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Print
Public Sub TBPrintRecord()
    cModule = "Sales_Order"
    oPrint.PrintReceipt Trim(txtSONo)
End Sub

Public Sub TBReference()
    RepName = "SO"
    frmReferenceTrans.mReferType = JSO
    frmReferenceTrans.mRefPK = txtSONo
    frmReferenceTrans.Show 1
End Sub


'Sets the data source of the controls
Sub SetDataSource()
    Set FrmName = Me
    BindControls rsHeader
    Set dtgList.DataSource = rsHeader
    Set dtgSO.DataSource = rsDetail
    Set txtLongDesc.DataSource = rsDetail
    
End Sub
    
'Sets the data field for every bounded controls
Sub SetDataField()
On Error GoTo ErrorHandler
    With rsHeader
        txtSONo.DataField = !cSONO
        dtbDate.DataField = !dDate
        txtType.DataField = !cType
        txtCode.DataField = !cCode
        txtAddress.DataField = !cAddress
        txtContact.DataField = !cContact
        txtDelCode.DataField = !cDelCode
        txtDelAddress.DataField = !cDelAddress
        txtDelContact.DataField = !cDelContact
        txtSMCode.DataField = !cSMan
        txtMSCode.DataField = !cMSCode
        txtPCCode.DataField = !cPCCode
        txtRemarks.DataField = !cRemarks
        'txtTPCName.DataField = !cTPCName
        txtGross.DataField = !nGross
        txtDiscount.DataField = !nDiscount
        txtNet.DataField = !nNet
        txtIntTerms.DataField = !cIntTerm
        txtTerms.DataField = !cTerm
        txtPaymentType.DataField = !cPayType
        txtCurrency.DataField = !cCurrency
        txtCurrencyRate.DataField = !nCurrencyRate
        txtCPONo.DataField = !cCPONo
        dtgExpiration.DataField = !dExpiration
        txtDCode.DataField = !cDCode
        txtTruckerCode.DataField = !cTruckerCode
        txtTruckerName.DataField = !cTruckerName
        dtbShipping.DataField = !dShpping
        txtTruckerVessel.DataField = !cTruckerVessel
        txtTruckerAdd.DataField = !cTruckerAdd
        txtTruckerContact.DataField = !cTruckerContact
        txtTruckerTel.DataField = !cTruckerTel
        txtTruckerFax.DataField = !cTruckerFax
        txtTruckerDest.DataField = !cTruckerDest
        txtTruckerLine.DataField = !cTruckerLine
        txtPromo.DataField = !cPromo
        txtAddTo.DataField = !cWHMan
    End With
ErrorHandler:
    If err.Number = 440 Then
        'Resume Next
    ElseIf err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub

Private Sub rsHeader_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
On Error GoTo ErrorHandler
    
    If Not (rsHeader.EOF) Or Not (rsHeader.BOF) Then
        'Status bar setup
        sbRS.Panels(1) = "Record: " & IIf((rsHeader.AbsolutePosition = -2), "0", rsHeader.AbsolutePosition) & "/" & rsHeader.RecordCount
        
        If rsHeader.Status <> adRecNew Then
            txtSONo.Locked = True
        Else
            txtSONo.Locked = False
        End If
        
        If Mode = AddNewEdit Then
            Select Case rsHeader.Status
                Case adRecNew
                    sbRS.Panels(2) = "New"
                Case adRecModified
                    sbRS.Panels(2) = "Modified"
                Case Else
                    sbRS.Panels(2) = ""
            End Select
        Else
            sbRS.Panels(2) = ""
        End If
        
        GetChild
    
        If rsHeader!lCancelled = True Then
            sbRS.Panels(4) = IIf(IsNull(rsHeader!cCRemarks), "", Trim(rsHeader!cCRemarks))
            sbRS.Panels(5) = "CANCELLED"
            lblStatus.Caption = "Cancelled"
            lblStatus.ForeColor = &H8080FF
        ElseIf rsHeader!lCApproved = True Then
            sbRS.Panels(4) = ""
            sbRS.Panels(5) = ""
            lblStatus.Caption = "Approved"
            lblStatus.ForeColor = &HC0C0C0
        ElseIf rsHeader!lServed = True Then
            sbRS.Panels(4) = ""
            sbRS.Panels(5) = "SERVED"
            lblStatus.Caption = "Served"
            lblStatus.ForeColor = &HC0C0C0
        Else
            sbRS.Panels(4) = ""
            sbRS.Panels(5) = ""
            lblStatus.Caption = ""
            lblStatus.ForeColor = &HC0C0C0
        End If
    Else
        sbRS.Panels(1) = "Record: 0/0"
        sbRS.Panels(2) = ""
        txtSONo.Locked = False
    End If
    
    If Mode = AddNewEdit Then
        dtgSO.Refresh
    End If
    
ErrorHandler:
    'Err.Number -2147217885
    'Description - Row handle referred to a deleted row or a row marked for deletion.
    If err.Number = -2147217885 Then
        Resume Next
    End If
End Sub

'Private Sub Timer1_Timer()
'    If Mode = AddNewEdit Then
'        SSTab1.TabEnabled(1) = False
'        'cmdServe.Enabled = False
'    Else
'        SSTab1.TabEnabled(1) = True
'        'cmdServe.Enabled = True
'    End If
'End Sub



Private Sub txtAddTo_Change()
    txtAddToName = ""
    txtAddToName = GetValueFrTable("cEmpName", "EMPLOYEE", "cEmpCode = '" & Trim(txtAddTo) & "'")
End Sub

Private Sub txtDCode_LabelClick()
    'oLink.LinkForm frmMaintCustomer, "Customer", Trim(txtDCode)
End Sub

Private Sub txtDelCode_LabelClick()
    'oLink.LinkForm frmMaintCustomer, "Customer", Trim(txtDelCode)
End Sub

Private Sub txtMSCode_LabelClick()
    'oLink.LinkForm frmMaintClassification, "Market Segment", Trim(txtMSCode)
End Sub


Private Sub txtDCode_Change()
    txtDName = ""
    txtDName = GetValueFrTable("cName", "TRUCKER", "cTruckerCode = '" & Trim(txtDCode) & "'")
End Sub

Private Sub txtPromo_Change()
    txtPromoName = ""
    txtPromoName = GetValueFrTable("cEmpName", "EMPLOYEE", "cEmpCode = '" & Trim(txtPromo) & "'")
End Sub

Private Sub txtSONo_Change()
'    If lApprovalShow = True Then
'        TBFindPrimary
'        lApprovalShow = False
'    End If
End Sub

Private Sub txtTruckerCode_Change()
If Mode <> AddNewEdit Then Exit Sub
    txtTruckerName = ""
    txtTruckerName = GetValueFrTable("cTruckerName", "SO", "cTruckerCode = '" & Trim(txtTruckerCode) & "'")
    If txtTruckerName <> "" Then
        txtTruckerAdd = GetValueFrTable("cAddress", "TRUCKER", "cTruckerCode = '" & Trim(txtTruckerCode) & "'")
        txtTruckerContact = GetValueFrTable("cContact", "TRUCKER", "cTruckerCode = '" & Trim(txtTruckerCode) & "'")
        txtTruckerTel = GetValueFrTable("cTel", "TRUCKER", "cTruckerCode = '" & Trim(txtTruckerCode) & "'")
        txtTruckerFax = GetValueFrTable("cFax", "TRUCKER", "cTruckerCode = '" & Trim(txtTruckerCode) & "'")
        txtTruckerType = GetValueFrTable("cType", "TRUCKER", "cTruckerCode = '" & Trim(txtTruckerCode) & "'")
    End If
End Sub

Private Sub txtTruckerDest_LostFocus()
    If txtTruckerDest = "" Then Exit Sub
    If GetValueFrTable("cLocation", "LOCATION", "cLocation = '" & Trim(txtTruckerDest) & "'") = "" Then cmdPickDestination_Click
End Sub

Private Sub txtTruckerVessel_KeyPress(KeyAscii As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    Select Case KeyAscii
        Case 13
            SSTab2.ActiveTab = 0
            TBNewLine
    End Select
End Sub

Private Sub txtType_Change()
Dim sCode As String
    If Trim(txtType) <> "" Or txtType <> vbNullString Then
        cboType = Trim(txtType)
    Else
        cboType.ListIndex = -1
    End If
    
    If Mode = AddNewEdit Then
        If rsHeader.Status = adRecNew Then
            Set rsAuto = Nothing
            Set rsAuto = New ADODB.Recordset
                Select Case Trim(cboType)
                    Case "Regular"
                        sCode = "SO_AUTO_RG"
                    Case "Employee"
                        sCode = "SO_AUTO_EM"
                    Case "Walk-in"
                        sCode = "SO_AUTO_WK"
                    Case "Vans"
                        sCode = "SO_AUTO_VN"
                    Case "Service"
                        sCode = "SO_AUTO_SR"
                    Case "Jobber"
                        sCode = "SO_AUTO_JB"
                    Case "Supplier"
                        sCode = "SO_AUTO_SU"
                    Case "Corporate"
                        sCode = "SO_AUTO_CO"
                    Case "Exhibit"
                        sCode = "SO_AUTO_EH"
                    Case "Demo/Sample"
                        sCode = "SO_AUTO_DS"
                    Case Else

                End Select
                
                sSQL = "select * from SYSTEM_OPTION where cCode = '" & sCode & "' and cCompanyID = '" & COID & "'"
                rsAuto.Open sSQL, cn, adOpenKeyset, adLockReadOnly
                
                If rsAuto.RecordCount <> 0 Then
                    If rsAuto!lBit Then
                        GetCtrlNo rsAuto!cCode
                    End If
                End If
        End If
        
        txtCode = ""
        txtDCode = ""
        
        If Trim(cboType) = "Jobber" Then
            txtDCode.Locked = False
            cmdPickDCode.Enabled = True
        Else
            txtDCode.Locked = True
            cmdPickDCode.Enabled = False
        End If
    End If
End Sub

Private Sub txtCode_Change()
On Error Resume Next

    txtName = ""
    txtName = GetValueFrTable("cName", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtCode) & "'")
    
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtName) <> "" Then
        rsHeader!cDelCode = txtCode
        rsHeader!cAddress = GetAddress("CLIENT_CUSTOMER", "cCode = '" & Trim(txtCode) & "'") & ""
        rsHeader!cContact = GetValueFrTable("cContact", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtCode) & "'")
        rsHeader!cMSCode = GetValueFrTable("cMSCode", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtCode) & "'")
        If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'CLNT_MAN_USERDFSMAN'") = True Then
            GetUser txtSMCode, txtSMName
        Else
            rsHeader!cSMan = GetValueFrTable("cSMan", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtCode) & "'")
        End If
        rsHeader!cTerm = GetValueFrTable("cTerm", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtCode) & "'")
        rsHeader!cIntTerm = GetValueFrTable("cIntTerm", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtCode) & "'")
        txtAddress.SetFocus
    Else
        txtDelCode = ""
        txtAddress = ""
        txtContact = ""
        txtMSCode = ""
        txtSMCode = ""
        cboTerms.ListIndex = -1
        cboIntTerms.ListIndex = -1
    End If
End Sub

Private Sub txtCode_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtName) = "" And Trim(txtCode) <> "" Then cmdPickCode_Click
End Sub

Private Sub txtCPONo_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        SSTab2.ActiveTab = 2
    End If
End Sub

Private Sub txtCurrency_Change()
    If Trim(txtCurrency) <> "" Or txtCurrency <> vbNullString Then
        cboCurrency = Trim(txtCurrency)
    Else
        cboCurrency.ListIndex = -1
    End If
End Sub

Private Sub txtDelCode_Change()
On Error Resume Next
'If Mode <> AddNewEdit Then Exit Sub
    txtDelName = ""
    txtDelName = GetValueFrTable("cName", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtDelCode) & "'")
    If Trim(txtDelName) <> "" Then
        txtDelAddress = GetAddress("CLIENT_CUSTOMER", "cCode = '" & Trim(txtDelCode) & "'") '+ ", " + GetValueFrTable("cCity", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtDelCode) & "'")
        txtDelContact = GetValueFrTable("cContact", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtDelCode) & "'")
        txtPhone1 = GetValueFrTable("cTel1", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtDelCode) & "'")
        txtPhone2 = GetValueFrTable("cTel2", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtDelCode) & "'")
        txtFax = GetValueFrTable("cFax", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtDelCode) & "'")
        txtEMail1 = GetValueFrTable("cEMail1", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtDelCode) & "'")
    Else
        txtDelAddress = ""
        txtDelContact = ""
        txtPhone1 = ""
        txtPhone2 = ""
        txtFax = ""
        txtEMail1 = ""
    End If
    
    Select Case rsHeader!cType
        Case "Regular", "Service", "Jobber", _
            "Exhibit", "Demo/Sample" 'client_customer
'            txtDelName = GetValueFrTable("cName", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtDelCode) & "'")
'            txtDelAddress = GetValueFrTable("cAddress", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtDelCode) & "'") + ", " + GetValueFrTable("cCity", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtDelCode) & "'")
'            txtDelContact = GetValueFrTable("cContact", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtDelCode) & "'")
        Case "Employee" 'employee
'            txtDelName = GetValueFrTable("cEmpName", "EMPLOYEE", "cEmpCode = '" & Trim(txtDelCode) & "'")
        Case "Walk-in" 'other customer
'            txtDelName = GetValueFrTable("cName", "CLIENT_OTHERS", "cCode = '" & Trim(txtDelCode) & "'")
        Case "Vans" 'salesman
'            txtDelName = GetValueFrTable("cName", "SALESMAN", "cCode = '" & Trim(txtDelCode) & "'")
        Case "Supplier" 'supplier
'            txtDelName = GetValueFrTable("cName", "CLIENT_SUPPLIER", "cCode = '" & Trim(txtDelCode) & "'")
    End Select

    If Mode <> AddNewEdit Then Exit Sub
'    If Trim(txtDelName) = "" Then
'        rsHeader!cDelAddress = ""
'        rsHeader!cDelContact = ""
'        txtDelCode.SetFocus
'    End If
End Sub


Private Sub txtDelCode_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtDelName) = "" And Trim(txtDelCode) <> "" Then cmdPickDelCode_Click
End Sub

Private Sub txtDelContact_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        SSTab2.ActiveTab = 3
    End If
End Sub


Private Sub txtDiscount_Change()
    ComputeTotal
End Sub

Private Sub txtLongDesc_KeyPress(KeyAscii As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub txtLongDesc_LostFocus()
    txtLongDesc.Visible = False
    dtgSO.Col = 4
    dtgSO.SetFocus
End Sub

Private Sub txtMSCode_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtMSDesc) = "" And Trim(txtMSCode) <> "" Then cmdPickMS_Click
End Sub

Private Sub txtPaymentType_Change()
    If Trim(txtPaymentType) <> "" Or txtPaymentType <> vbNullString Then
        cboPaymentType = Trim(txtPaymentType)
    Else
        cboPaymentType.ListIndex = -1
    End If
End Sub

Private Sub txtPCCode_Change()
    txtPCDesc = ""
    txtPCDesc = GetValueFrTable("cDescription", "PROFITCENTER", "cPCCode = '" & Trim(txtPCCode) & "'")
End Sub

Private Sub txtPCCode_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtPCDesc) = "" And Trim(txtPCCode) <> "" Then cmdPickPC_Click
End Sub

Private Sub txtSMCode_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtSMName) = "" And Trim(txtSMCode) <> "" Then cmdPickSM_Click
End Sub

Private Sub txtSONo_LostFocus()
    'Does Code Already exists
    If Mode = AddNewEdit Then
    
        If Trim(txtSONo) = "" Then
            MsgBox "Empty primary input.", vbInformation, "ComUnion"
            If FrmName.Name <> Me.Name Then PreviousTab frmComUnionMenuTab
            txtSONo.SetFocus
            Exit Sub
        Else
            If rsHeader.Status <> adRecNew Then Exit Sub
            txtSONo = Trim(txtSONo)
            If IDExisting(rsHeader, "cSONo", "SO", Trim(rsHeader!cSONO), "cType <> 'EXPORT'") Then
                MsgBox "Sales order No. already exists.", vbInformation, "ComUnion"
                If FrmName.Name <> Me.Name Then PreviousTab frmComUnionMenuTab
                txtSONo.SetFocus
                Exit Sub
            End If
        End If
    End If
    
End Sub

Private Sub txtIntTerms_Change()
    If Trim(txtIntTerms) <> "" Or txtIntTerms <> vbNullString Then
        cboIntTerms = Trim(txtIntTerms)
    Else
        cboIntTerms.ListIndex = -1
    End If
End Sub

Private Sub txtMSCode_Change()
'If Mode <> AddNewEdit Then Exit Sub
    txtMSDesc = ""
    txtMSDesc = GetValueFrTable("cDescription", "CLASSIFICATION", "cClassCode = '" & Trim(txtMSCode) & "' AND cType = 'MS'")
End Sub

Private Sub txtSMCode_Change()
'If Mode <> AddNewEdit Then Exit Sub
    txtSMName = ""
    txtSMName = GetValueFrTable("cName", "SALESMAN", "cCode = '" & Trim(txtSMCode) & "'")
End Sub

Private Sub txtTerms_Change()
    If Trim(txtTerms) <> "" Or txtTerms <> vbNullString Then
        cboTerms = Trim(txtTerms)
    Else
        cboTerms.ListIndex = -1
    End If
End Sub

'Check if all mandatory fields are complete
Function MandatoryOK() As Boolean
On Error GoTo ErrorHandler
    MandatoryOK = True
    
    If Trim(txtSONo) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Order Number' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        txtSONo.SetFocus
        Exit Function
    End If
    
    If rsHeader.Status = adRecNew And lSystemGeneratedSO = False Then
        If IDExisting(rsHeader, "cSONo", "SO", Trim(rsHeader!cSONO), "cType <> 'EXPORT'") Then
            MandatoryOK = False
            MsgBox "Sales order No. already exists.", vbInformation, "ComUnion"
            txtSONo.SetFocus
            Exit Function
        End If
    End If
        
    'Required fields
    If Trim(dtbDate.Text) = "__/__/____" Then
        MandatoryOK = False
        MsgBox "Field 'Order Date' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        dtbDate.SetFocus
        Exit Function
    ElseIf Trim(txtType) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Order Type' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        cboType.SetFocus
        Exit Function
    ElseIf Trim(txtCode) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Customer' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        txtCode.SetFocus
        Exit Function
    ElseIf Trim(txtDelCode) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Delivery Customer' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        txtDelCode.SetFocus
        Exit Function
'    ElseIf Trim(txtMSCode) = "" Then
'        MandatoryOK = False
'        MsgBox "Field 'Market Segment' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
'        txtMSCode.SetFocus
'        SSTab2.ActiveTab = 1
'        Exit Function
'    ElseIf Trim(txtPCCode) = "" Then
'        MandatoryOK = False
'        MsgBox "Field 'Unit Division' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
'        txtPCCode.SetFocus
'        SSTab2.Tab = 1
'        Exit Function
    ElseIf Trim(txtSMCode) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Salesman' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        txtSMCode.SetFocus
        SSTab2.ActiveTab = 0
        Exit Function
    ElseIf Trim(txtIntTerms) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Internal Terms' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        cboIntTerms.SetFocus
        Exit Function
    ElseIf Trim(txtTerms) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Actual Terms' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        cboTerms.SetFocus
        Exit Function
    ElseIf Trim(txtPaymentType) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Payment Type' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        cboPaymentType.SetFocus
        Exit Function
    End If
    
    GetChild
    
    'Transaction without details
    If rsDetail.RecordCount = 0 Then
        MandatoryOK = False
        MsgBox "Cannot save transaction without details.", vbInformation, "ComUnion"
        dtgSO.SetFocus
        Exit Function
    End If
        
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        If Trim(cboType) = "For Consignment" Then rsDetail!lDRReady = True
        If Trim(cboType) = "For Sales-Con" Then rsDetail!lDRReady = True
        If Trim(rsDetail!cStatus) = "Available" Then rsDetail!lDRReady = True
        If lAutoStock Then rsDetail!lDRReady = True
        If rsDetail.Status = (adRecNew) Or rsDetail.Status = (adRecModified) Then
            If IsNull(rsDetail!cItemNo) Then
                rsDetail.Delete
            ElseIf Trim(rsDetail!cItemNo) = "" Then
                rsDetail.Delete
            Else
                rsDetail.MoveNext
            End If
        Else
            rsDetail.MoveNext
        End If
    Loop
    
    GetChild
    
    If rsDetail.RecordCount < 1 Then
        MsgBox "Cannot save transaction without details.", vbExclamation, "ComUnion"
        MandatoryOK = False
        Exit Function
    End If

    If (Trim(cboType) = "For Consignment") Or (Trim(cboType) = "For Sales-Con") Then
        rsHeader!lCApproved = True
        rsHeader!lPApproved = True
    End If
ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
        MsgBox "Cannot save transaction, please refresh data!", vbExclamation, "ComUnion"
    End If
End Function

'Filter detail recordset to header's primary
Private Sub GetChild()
    rsDetail.Filter = "cSONo = '" & Trim(rsHeader!cSONO) & "'"
End Sub

'Sets the form if record number is zero
Private Sub RSZero()
    sbRS.Panels(1) = "Record: 0/0"
    sbRS.Panels(2) = ""
    sbRS.Panels(4) = ""
    sbRS.Panels(5) = ""
    
    Set dtgSO.DataSource = Nothing
    dtgSO.Refresh
    
    Set FrmName = Me
    UnbindControls
    TextClearing
    FormLocking True
    
    If rsHeader.State = adStateOpen Then rsHeader.Close
    If rsDetail.State = adStateOpen Then rsDetail.Close
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
    
    txtSONo.Locked = False
    txtSONo.SetFocus
    
    Mode = Find
End Sub

Sub SearchObj(lEnable As Boolean)
    dtbDate.Enabled = lEnable
    cboType.Enabled = lEnable
    cmdPickCode.Enabled = lEnable
    cmdPickSM.Enabled = lEnable
    cboIntTerms.Enabled = lEnable
    cboTerms.Enabled = lEnable
    cboPaymentType.Enabled = lEnable
    cmdPickMS.Enabled = lEnable
    cmdPickDCode.Enabled = lEnable
    cboCurrency.Enabled = lEnable
    dtgExpiration.Enabled = lEnable
    cmdPickDelCode.Enabled = lEnable
    cmdPickTrucker.Enabled = lEnable
End Sub

'Gets initital item values
Private Sub GetInitialItemValues()
On Error GoTo ErrorHandler
Dim xPM As String
    rsDetail!cDesc = Trim(GetValueFrTable("cDesc", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")) & ""
    rsDetail!cUnit = Trim(GetValueFrTable("cUnit", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")) & ""
    rsDetail!cPricing = "SRP"
    rsDetail!nPrice = Trim(GetValueFrTable("nSRPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")) & ""
    rsDetail!nNetPrice = rsDetail!nPrice
    xPM = GetValueFrTable("cPMID", "Client_Customer", "cCode = '" & Trim(rsHeader!cCode) & "'")
    GetCommission
    If xPM <> "" Then
        Select Case GetValueFrTable("cType", "PM", "cPMID = '" & Trim(xPM) & "'")
            Case "Market Segment"
                rsDetail!cPricing = "Pricing MS"
                If Me.txtMSCode <> GetValueFrTable("cReference", "PM", "cPMID = '" & Trim(xPM) & "'") Then Exit Sub
                rsDetail!cUnit = GetValueFrTable("cUnit", "PM_T", "cPMID = '" & Trim(xPM) & "' and cItemNo = '" & Trim(rsDetail!cItemNo) & "'")
                rsDetail!nPrice = GetValueFrTable("nPrice", "PM_T", "cPMID = '" & Trim(xPM) & "' and cItemNo = '" & Trim(rsDetail!cItemNo) & "'")
                rsDetail!cDiscount = GetValueFrTable("cDiscount", "PM_T", "cPMID = '" & Trim(xPM) & "' and cItemNo = '" & Trim(rsDetail!cItemNo) & "'")
            Case "Customer"
                rsDetail!cPricing = "Pricing Client"
                rsDetail!cUnit = GetValueFrTable("cUnit", "PM_T", "cPMID = '" & Trim(xPM) & "' and cItemNo = '" & Trim(rsDetail!cItemNo) & "'")
                rsDetail!nPrice = GetValueFrTable("nPrice", "PM_T", "cPMID = '" & Trim(xPM) & "' and cItemNo = '" & Trim(rsDetail!cItemNo) & "'")
                rsDetail!cDiscount = GetValueFrTable("cDiscount", "PM_T", "cPMID = '" & Trim(xPM) & "' and cItemNo = '" & Trim(rsDetail!cItemNo) & "'")
            Case "Terms"
                rsDetail!cPricing = "Pricing Terms"
                If Me.txtIntTerms <> GetValueFrTable("cReference", "PM", "cPMID = '" & Trim(xPM) & "'") Then Exit Sub
                rsDetail!cUnit = GetValueFrTable("cUnit", "PM_T", "cPMID = '" & Trim(xPM) & "' and cItemNo = '" & Trim(rsDetail!cItemNo) & "'")
                rsDetail!nPrice = GetValueFrTable("nPrice", "PM_T", "cPMID = '" & Trim(xPM) & "' and cItemNo = '" & Trim(rsDetail!cItemNo) & "'")
                rsDetail!cDiscount = GetValueFrTable("cDiscount", "PM_T", "cPMID = '" & Trim(xPM) & "' and cItemNo = '" & Trim(rsDetail!cItemNo) & "'")
            Case "Area"
                'rsDetail!cPricing = "Pricing Terms"
        End Select
    rsDetail!nFactor = GetValueFrTable("nFactor", "ITEM_Unit", "cItemNo = '" & Trim(rsDetail!cItemNo) & "' and cUnit = '" & Trim(rsDetail!cUnit) & "'")
    End If
    
    Dim rsBal As New ADODB.Recordset
'    ProductBalanceCommand rsBal, rsDetail!cItemNo, sCustCode
    sSQL = "exec SP_ProductBalanceInquiry_Module '" & rsDetail!cItemNo & "', '" & sBarcodeID & "','" & COID & "'"
    rsBal.Open , cn, adOpenStatic, adLockOptimistic
    If rsBal.RecordCount > 0 Then
        If rsBal!nBalance <= 0 Then
            rsDetail!cStatus = "No Stock"
            dtgSO.Columns(4).Value = 0
        Else
            rsDetail!cStatus = "Available"
'            dtgSO.Columns(4).Value = rsBal!nBalance - rsBal!nReserved
            dtgSO.Columns(4).Value = 0
        End If
    Else
        rsDetail!cStatus = "Available"
        dtgSO.Columns(4).Value = 0
    End If
    rsBal.Close
    Set rsBal = Nothing
    
    Select Case UCase(Trim(GetValueFrTable("cType", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")))
        Case "ASSEMBLY"
            If rsDetail!cStatus = "No Stock" Then rsDetail!cStatus = "Production"
        Case "BUY-OUT"
            If rsDetail!cStatus = "No Stock" Then rsDetail!cStatus = "Buy-out"
    End Select
    
    aQty(rsDetail.AbsolutePosition) = rsDetail!nQty
    
    ComputeAmount
    ComputeTotal
ErrorHandler:
    If err.Number <> 0 And err.Number <> -2147217908 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    Else
'        GetConPrice
        rsDetail!cStatus = "Available"
        dtgSO.Columns(10).Value = "Available"
        dtgSO.Columns(4).Value = 0
        Select Case UCase(Trim(GetValueFrTable("cType", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")))
            Case "ASSEMBLY"
                If rsDetail!cStatus = "No Stock" Then rsDetail!cStatus = "Production"
            Case "BUY-OUT"
                If rsDetail!cStatus = "No Stock" Then rsDetail!cStatus = "Buy-out"
        End Select
        
        aQty(rsDetail.AbsolutePosition) = rsDetail!nQty
        
        ComputeAmount
        ComputeTotal
    End If
End Sub

Private Function GetSearchString() As String
On Error GoTo ErrorHandler
Dim sWhere As String

    GetSearchString = True

    If Trim$(txtSONo.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cSONo LIKE '" & Trim$(txtSONo.Text) & "%'"
    End If

    If Trim$(dtbDate.Text) <> "__/__/____" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " dDate = '" & Trim$(dtbDate.Text) & "'"
    End If
    
    If Trim$(cboType) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cType = '" & Trim$(cboType) & "'"
    End If
    
    If Trim$(txtCode.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cCode LIKE '" & Trim$(txtCode.Text) & "%'"
    End If
    
    If Trim$(txtSMCode.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cSMan LIKE '" & Trim$(txtSMCode.Text) & "%'"
    End If
    
    If Trim$(txtIntTerms.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cIntTerm LIKE '" & Trim$(txtIntTerms.Text) & "%'"
    End If
    
    If Trim(txtTerms.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cTerm LIKE '" & Trim$(txtTerms.Text) & "%'"
    End If
    
    If Trim(txtPaymentType.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cPayType LIKE '" & Trim$(txtPaymentType.Text) & "%'"
    End If
    
    If Trim(txtMSCode.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cMSCode LIKE '" & Trim$(txtMSCode.Text) & "%'"
    End If
    
    If Trim(txtDCode.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cDCode LIKE '" & Trim$(txtDCode.Text) & "%'"
    End If
    
    If Trim(txtCurrency.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cCurrency LIKE '" & Trim$(txtCurrency.Text) & "%'"
    End If
    
    If Trim(dtgExpiration.Text) <> "__/__/____" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " dExpiration = '" & Trim$(dtgExpiration.Text) & "'"
    End If
    
    If Trim(txtCPONo.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cCPONo LIKE '" & Trim$(txtCPONo.Text) & "%'"
    End If
    
    If Trim(txtDelCode.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cDelCode LIKE '" & Trim$(txtDelCode.Text) & "%'"
    End If
    
    If Trim(txtTruckerCode.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cTruckerCode LIKE '" & Trim$(txtTruckerCode.Text) & "%'"
    End If
    
    GetSearchString = Trim$(sWhere)

    Exit Function
ErrorHandler:
    GetSearchString = "ERROR"
End Function

Private Sub GetConPrice()
If Trim(rsHeader!cType) = "Consignment" Then
    rsDetail!cPricing = "Pricing Client"
End If
If GetValueFrTable("cCustCode", "ITEM", "cItemNo = '" & rsDetail!cItemNo & "'") <> "" Then
    rsDetail!cBarcodeID = GetValueFrTable("cPartNo", "ITEM", "cItemNo = '" & rsDetail!cItemNo & "'")
Else
     rsDetail!cBarcodeID = rsDetail!cItemNo
End If
If GetCustomerCode = True Then rsDetail!cCustCode = sCustCode
GetInitialItemValues
If Trim(rsHeader!cType) = "Consignment" Then
    rsDetail!cPricing = "Pricing Client"
End If
If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'CLNT_MAN_COMMISSION'") = True Then
    If GetValueFrTable("cItemNo", "COMMISSION_CUSTOMER", "cItemNo = '" & rsDetail!cItemNo & "' and cCode = '" & rsHeader!cCode & "'") <> "" Then
        rsDetail!cDiscount = GetValueFrTable("nCommission", "COMMISSION_CUSTOMER", "cItemNo = '" & rsDetail!cItemNo & "' and cCode = '" & rsHeader!cCode & "'")
        dtgSO.Col = 7
        dtgSO_KeyPress 13
    Else
        rsDetail!cDiscount = GetValueFrTable("nCommission", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'")
        dtgSO.Col = 7
        dtgSO_KeyPress 13
    End If
End If
End Sub

'Computes multi-level discount
Private Sub ComputeNet()
On Error GoTo ErrorHandler
Dim si, l As Integer
Dim s(0 To 15), ns, disc As String
Dim lStop As Boolean
    
    lNetOK = True
    
    If rsDetail.RecordCount = 0 Then Exit Sub
    If IsNull(rsDetail!cItemNo) Then Exit Sub
    If Trim(rsDetail!cItemNo) = "" Then Exit Sub
    
    lNetOK = False

    rsDetail!cDiscount = Trim(dtgSO.Columns(7).Text)                                     ' discount
    disc = rsDetail!cDiscount
    net = dtgSO.Columns(6).Value 'rsDetail!nPrice  'dtgSO.Columns(6).Value      'price
    
    If disc <> "" Then
        l = Len(disc)
        i = 1
        si = 0
        Do While Not i = l + 1
            cString = Mid(disc, i, 1)
            If cString <> "/" Then
                ns = ns + cString
                s(si) = ns
            Else
                si = si + 1
                ns = ""
            End If
            i = i + 1
        Loop
                
        si = 0
        lStop = False
        
        Do While Not lStop
            If s(si) <> "" Then
                If Not IsNumeric(s(si)) Then GoTo ErrorHandler
                si = si + 1
            Else
                lStop = True
            End If
        Loop
        
        si = 0
        lStop = False
        
        Do While Not lStop
            If s(si) <> "" Then
                If Right(s(si), 1) = "-" Then GoTo ErrorHandler
                If (Mid(s(si), 1, 1) = "-") Then
                    net = net + CDbl(s(si))
                Else
                    net = net - (net * (CDbl(s(si)) * 0.01))
                End If
                si = si + 1
            Else
                lStop = True
            End If
        Loop
    
    End If
    
    If s(0) = "" Then dtgSO.Columns(7).Text = ""    'Discount
    
    dtgSO.Columns(8).Value = Round(net, 4)   'netPrice
    lNetOK = True
    
ErrorHandler:
    If Not lNetOK Then
        MsgBox "Invalid discount format! (ex: '10/5/-100', '-100/10/5', '10/-100/5')", vbCritical, "ComUnion"
        lLessAmount = False
        lLessPercent = False
    End If

End Sub

'Computes total amount per detail line
Private Sub ComputeAmount()
On Error Resume Next
Dim nAmount As Double
    If Mode <> AddNewEdit Then Exit Sub
    With dtgSO
    
        nAmount = IIf(IsNull(.Columns(8).Value), 0, .Columns(8).Value) * IIf(IsNull(.Columns(4).Value), 0, .Columns(4).Value)
        .Columns(9).Value = net * CDec(IIf(IsNull(.Columns(4).Value), 0, .Columns(4).Value))
    End With
End Sub

'Computes total amount of order
Public Sub ComputeTotal()
Dim n As Double
    
On Error Resume Next
    
    If Mode <> AddNewEdit Then Exit Sub
    
    n = 0
    Set rs = New Recordset
    Set rs = rsDetail.Clone
    rs.Filter = "cSONo = '" & Trim(rsHeader!cSONO) & "'"

    rs.MoveFirst
    Do Until rs.EOF
        n = n + IIf(IsNull(rs!nAmount), 0, rs!nAmount)
        rs.MoveNext
    Loop
    Set rs = Nothing
    
    rsHeader!nGross = n
    rsHeader!nNet = n
    rsHeader!nNet = n - IIf(IsNull(rsHeader!nDiscount), 0, rsHeader!nDiscount)
    
End Sub

Private Sub GetCtrlNo(sCode As String)
Dim lCtrlNoOK As Boolean

    strNo = rsAuto!cValue
    Do Until lCtrlNoOK
        If IDExisting(rsHeader, "cSONo", "SO", Left(strNo, 5) + Format(CStr((CInt(Right(strNo, 4)) + 1)), "0000")) Then
            strNo = Left(strNo, 5) + Format(CStr((CInt(Right(strNo, 4)) + 1)), "0000")
        Else
            lCtrlNoOK = True
        End If
    Loop
    
    If Mid(strNo, 4, 2) <> Format(Date, "yy") Then
        txtSONo = Format(1, "0000")
        strNo = Left(strNo, 3) + Format(Date, "yy") + "0000"
    Else
        txtSONo = Left(strNo, 3) + Format(Date, "yy") + Format(Right(strNo, 4) + 1, "0000")
    End If
End Sub

'Check system generated number before saving
Function CheckCtrlNo() As Boolean

Dim lCtrlNoOK As Boolean
Dim strNewNo As String
Dim strNewSONo As String
Dim sTrap

On Error GoTo TheSource

    CheckCtrlNo = False
    
    If IDExisting(rsHeader, "cSONo", "SO", rsHeader!cSONO) Then
        sTrap = Left(txtSONo, 5) & (Format(Right(txtSONo, 4) - 1, "0000"))
        
        strNewNo = Trim(GetValueFrTable("cValue", "SYSTEM_OPTION", "cCode = '" & rsAuto!cCode & "' "))
        
        Do Until lCtrlNoOK
            If IDExisting(rsHeader, "cSONo", "SO", Left(strNewNo, 5) + Format(CStr((CInt(Right(strNewNo, 4)) + 1)), "0000")) Then
                strNewNo = Left(strNewNo, 5) + Format(CStr((CInt(Right(strNewNo, 4)) + 1)), "0000")
            Else
                lCtrlNoOK = True
            End If
        Loop
        
        If Mid(strNewNo, 4, 2) <> Format(Date, "yy") Then
            strNewSONo = Format(1, "0000")
            strNewNo = Left(rsAuto!cValue, 3) + Format(Date, "yy") + "0000"
        Else
            strNewSONo = Left(rsAuto!cValue, 3) + Format(Date, "yy") + Format(Right(strNewNo, 4) + 1, "0000")
        End If
        
        GetChild
        
        rsHeader!cSONO = strNewSONo
        If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
        Do Until rsDetail.EOF
            rsDetail!cSONO = strNewSONo
            rsDetail.MoveNext
        Loop
        
        GetChild
        
        strNo = strNewNo
    End If
    
    CheckCtrlNo = True
    
TheSource:
    If Not CheckCtrlNo Then
        If MsgBox("Record cannot be updated. Transaction number already exists. " & vbCr & _
                "Current transaction number may have been used by other user/s since last read." & vbCr & _
                "Do you want to assign another number?", vbYesNo + vbInformation, "ComUnion") = vbYes Then
            frmChangeTranNo.mType = Change_SONo
            frmChangeTranNo.Show vbModal
        Else
            MsgBox "Transaction will be undone.", vbInformation, "ComUnion"
            TBUndoAll
        End If
    End If
End Function

'Update system generated number
Sub UpdateCtrlNo()
On Error GoTo TheSource
   
    If (Left(txtSONo, 5) & (Format(Right(txtSONo, 4) - 1, "0000"))) <> (strNo) Then Exit Sub
    sSQL = "UPDATE SYSTEM_OPTION set cValue = '" & Trim(txtSONo) & "' WHERE cCode = " & rsAuto!cCode & " AND cCompanyID = '" & COID & "'"
    cn.Execute sSQL

TheSource:
    Exit Sub
End Sub


Private Function AllowEdit() As Boolean
    AllowEdit = True
    
    'Cannot edit if transaction was already approved
    If rsHeader!lCApproved = True Then
        MsgBox "Cannot edit approved transaction.", vbCritical + vbExclamation, "ComUnion"
        AllowEdit = False
        Exit Function
    End If
    
End Function

Private Function AllowDelete(sAction As String) As Boolean
    AllowDelete = True
    
    If sAction <> "cancel" Then
        'Cannot delete if transaction was already approved
        If rsHeader!lCApproved = True Then
            MsgBox "Cannot " & sAction & " approved transaction.", vbCritical + vbExclamation, "ComUnion"
            AllowDelete = False
            Exit Function
        End If
    Else
        If GetValueFrTable("cSONo", "V_SOTransactions", "cSONo = '" & Trim(txtSONo) & "'") <> "" Then
            MsgBox "Cannot " & sAction & " referenced SO transaction.", vbCritical + vbExclamation, "ComUnion"
            AllowDelete = False
            Exit Function
        End If
    End If

End Function

'Change Transaction Number
Sub ChangeTranNo(strTranNo As String)
    GetChild
    
    rsHeader!cSONO = strTranNo
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        rsDetail!cSONO = strTranNo
        rsDetail.MoveNext
    Loop
    
    GetChild
End Sub

Public Sub ShowTran()
On Error GoTo ErrorHandler
    If Mode = Find Then

        OpenNewConnection connHeader
        OpenNewConnection connDetail

        Set rsHeader = Nothing
        Set rsDetail = Nothing
        Set rsHeader = New ADODB.Recordset
        Set rsDetail = New ADODB.Recordset

        OpenRecordsetWithCN rsDetail, "*", "SO_T", connDetail, "WHERE cSONo = '" & Trim(txtSONo) & "'", True
        OpenRecordsetWithCN rsHeader, "*", "SO", connHeader, "WHERE cSONo = '" & Trim(txtSONo) & "'", True

        Set FrmName = Me
        FormLocking True

        If rsHeader.RecordCount = 0 Then
            FormWaitHide
            MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
            RSZero
            FormSearch True
            SearchObj True
            Mode = Find
            Exit Sub
        End If
            SetDataSource
            SetDataField
            txtSONo.BackColor = &HE0FFFF
            Mode = Normal
            BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , True, , , , True, , , True
'            oBar.BitEnabled Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , , , , True, True, , True

    End If
ErrorHandler:
    If err.Number <> 0 Then
        MsgBox err.Description, vbInformation, "ComUnion"
    End If
End Sub


Private Sub GetCustFromPM()
On Error GoTo err  'jomz

Dim rsCust As New ADODB.Recordset
Dim connCust As New ADODB.Connection

OpenNewConnection connCust

''if reference in price matrix is equal to customer code (set as default price and discount for subjected item)
'If GetValueFrTable("cReference", "PM a inner join pm_t b ON b.cCompanyID = a.cCompanyID AND b.cPMID = a.cPMID ", "cItemNo = '" & rsDetail!cItemNo & "' and dEffectDate <= '" & Date & "' and lCancelled = 0 and a.cCompanyID = '" & COID & "' and a.cType = 'Customer' and a.lPosted = 1 and a.lApproved = 1", True) = rsHeader!cCode Then
'    rsDetail!cPricing = "Pricing Client"
'    rsDetail!nUDPrice = GetValueFrTable("nPrice", "PM a inner join pm_t b ON b.cCompanyID = a.cCompanyID AND b.cPMID = a.cPMID ", "cItemNo = '" & rsDetail!cItemNo & "' and dEffectDate <= '" & Date & "' and lCancelled = 0 and a.cCompanyID = '" & COID & "' and lPosted = 1 and lApproved = 1", True)
'    rsDetail!cDiscount = GetValueFrTable("cDiscount", "PM a inner join pm_t b ON b.cCompanyID = a.cCompanyID AND b.cPMID = a.cPMID ", "cItemNo = '" & rsDetail!cItemNo & "' and dEffectDate <= '" & Date & "' and lCancelled = 0 and a.cCompanyID = '" & COID & "' and lPosted = 1 and lApproved = 1", True)
'Exit Sub 'exit when true
'End If

'get customer type if is member of wholesaler
If GetValueFrTable("cCustomerType", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'", True) = "Member" Then
'    Or GetValueFrTable("cCustomerType", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'", True) = "Wholesaler" Then 'Exit Sub
    
'    If IsNull(rsDetail!cPricing) Then
        'set pricing to customer type
        rsDetail!cPricing = GetValueFrTable("cCustomerType", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'", True)
'    End If
    
    
    sSQL = "Select nPrice,cDiscount from PM_T a inner join pm b " _
            & "ON b.cCompanyID = a.cCompanyID AND b.cPMID = a.cPMID " _
            & "where cReference = '" & GetValueFrTable("cCustomerType", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'", True) & "' and cItemNo = '" & rsDetail!cItemNo & "' " _
            & "and dEffectDate <= '" & Date & "' and lCancelled = 0 and b.cCompanyID = '" & COID & "' and b.lPosted = 1 and b.lApproved = 1"
    
    rsCust.Open sSQL, connCust, adOpenStatic, adLockOptimistic
    
    If rsCust.RecordCount = 0 Or (rsDetail!cPricing <> GetValueFrTable("cCustomerType", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'", True)) Then
        rsDetail!nUDPrice = 0
        rsDetail!nNetPrice = 0
        rsDetail!cDiscount = ""
    Else
        rsDetail!nPrice = rsCust!nPrice
        rsDetail!cDiscount = rsCust!cDiscount
    End If
Else
    rsDetail!cPricing = "Regular"
    cboSO = rsDetail!cPricing
    Exit Sub
End If
err: Exit Sub
End Sub

Private Sub GetRWMPrice()
If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'ITM_MAN_FACTOR'") = False Then
    rsDetail!nFactor = 1
End If
Select Case Trim(rsDetail!cPricing)
    Case "SRP"
        rsDetail!cBarcodeID = GetValueFrTable("cPartNo", "ITEM", "cItemNo = '" & rsDetail!cItemNo & "'")
        rsDetail!nPrice = IIf(GetValueFrTable("nSRPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'") = Null, 0, GetValueFrTable("nSRPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")) * rsDetail!nFactor
    Case "Regular"
'        rsDetail!cPricing = GetValueFrTable("cCustomerType", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'", True)
        If rsHeader!cType <> "Consignment" And rsHeader!cType <> "For Sales-Con" Then
            rsDetail!cBarcodeID = GetValueFrTable("cPartNo", "ITEM", "cItemNo = '" & rsDetail!cItemNo & "'")
            rsDetail!nPrice = IIf(GetValueFrTable("nSRPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'") = Null, 0, GetValueFrTable("nSRPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")) * rsDetail!nFactor
        Else
            GetConPrice
        End If
    Case "WSP"
        rsDetail!cBarcodeID = GetValueFrTable("cPartNo", "ITEM", "cItemNo = '" & rsDetail!cItemNo & "'")
        rsDetail!nPrice = IIf(GetValueFrTable("nWSPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'") = Null, 0, GetValueFrTable("nWSPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")) * rsDetail!nFactor
    Case "Wholesaler"
        rsDetail!cBarcodeID = GetValueFrTable("cPartNo", "ITEM", "cItemNo = '" & rsDetail!cItemNo & "'")
        rsDetail!nPrice = IIf(GetValueFrTable("nWSPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'") = Null, 0, GetValueFrTable("nWSPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")) * rsDetail!nFactor
    Case "Pricing MS"
        rsDetail!nPrice = 0
    Case "Pricing Terms"
        rsDetail!nPrice = 0
    Case "Pricing Client"
        rsDetail!nPrice = 0
    Case "FOC"
        rsDetail!nPrice = 0
    Case "Others"
        rsDetail!nPrice = 0
    Case "Member"
        rsDetail!cBarcodeID = GetValueFrTable("cPartNo", "ITEM", "cItemNo = '" & rsDetail!cItemNo & "'")
        GetCustFromPM
    Case "Promo"
        GetConPrice
    Case "Consignee"
        GetConPrice
End Select
rsDetail!nNetPrice = rsDetail!nPrice
ComputeAmount
ComputeTotal
End Sub

Function GetCustomerCode() As Boolean
'On Error Resume Next
'Dim rs As New ADODB.Recordset
'
'sCustCode = ""
'GetCustomerCode = False
'If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode ='ITM_MAN_USECUSTITEMNO'") = True Then
'    Set rs = New ADODB.Recordset
'
'    sSQL = "SELECT * FROM item_custcode a INNER JOIN item b " _
'            & "ON b.cItemNo = a.cItemNo AND b.cPartNo = a.cBarcodeID AND b.cCompanyID = a.cCompanyID " _
'            & "WHERE a.cItemNo = '" & Trim(rsDetail!cItemNo) & "' and a.cBarcodeID = '" & rsDetail!cBarcodeID & "'" _
'            & " and a.cCode = (select cGroupCode from client_customer where cCode = '" & Trim(txtCode) & "')"  ' '" & sCode & "'"
'    rs.Open sSQL, cn, adOpenStatic, adLockOptimistic
'    'sBarcodeID = rs!cBarcodeID
'    If rs.RecordCount <> 0 Then
'        sCustCode = rs!cStockNo & ""
'        GetCustomerCode = True
'    End If
On Error Resume Next
Dim rs As New ADODB.Recordset
Dim temp As String

temp = Trim(txtCode)

If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode ='CLNT_MAN_USEPARENTCOMPANY'") = True Then
    If GetValueFrTable("cGroupCode", "CLIENT_CUSTOMER", "cCode = '" & temp & "'") <> "" Or _
        GetValueFrTable("cGroupCode", "CLIENT_CUSTOMER", "cCode = '" & temp & "'") <> Null Then
        
        temp = GetValueFrTable("cGroupCode", "CLIENT_CUSTOMER", "cCode = '" & temp & "'")
        
    End If
End If

If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode ='ITM_MAN_USECUSTITEMNO'") = True Then
    Set rs = New ADODB.Recordset
    
    sSQL = "SELECT a.cStockNo FROM item_custcode a INNER JOIN item b " _
            & "ON b.cItemNo = a.cItemNo AND b.cPartNo = a.cBarcodeID AND b.cCompanyID = a.cCompanyID " _
            & "WHERE a.cItemNo = '" & Trim(rsDetail!cItemNo) & "' and a.cBarcodeID = '" & rsDetail!cBarcodeID & "'" _
            & " and a.cCode = '" & temp & "'" ' '" & sCode & "'"
    rs.Open sSQL, cn, adOpenStatic, adLockOptimistic
    
    If rs.RecordCount <> 0 Then
        sCustCode = rs!cStockNo & ""
        GetCustomerCode = True
    End If
    
    
End If

End Function

'Inserts into DR & DR_T tables
Private Function SOToDR() As Boolean
Dim rsDR As New ADODB.Recordset
Dim rsDR_T As New ADODB.Recordset
Dim rsTRIPTICKET As New ADODB.Recordset
Dim rsTRIPTICKET_T As New ADODB.Recordset
Dim cSO, cSO_T As String
Dim nSO_I As Long
Dim i As Integer

i = 1

On Error GoTo FunctionExit
    
    SOToDR = False

    cString = "SO-" & Trim$(rsHeader!cSONO)
    cSO = rsDetail!cRefNo
    
    cn.Execute ("DELETE DR_T WHERE cCompanyID = '" & COID & "' AND cDRNo = '" & Trim(cString) & "'")
    cn.Execute ("DELETE DR WHERE cCompanyID = '" & COID & "' AND cDRNo = '" & Trim(cString) & "'")
    
    GetChild
    
    OpenRecordset rsDR, "*", "DR", "WHERE 1 = 0"
    OpenRecordset rsDR_T, "*", "DR_T", "WHERE 1 = 0"
    
    With rsDR
        .AddNew
        !cCompanyID = COID
        !cDRNo = Trim$(cString)
        !dDate = rsHeader!dDate
        !cType = "Auto-DR"
        !cRemarks = "Auto-DR for " & Trim(rsHeader!cType) & "type SO"
        !cDelCode = Trim$(rsHeader!cCode)
'        !cInvNo = Trim$(rsHeader!cInvNo)
        !cGPNo = Trim$(cString)
        !nGross = rsHeader!nGross
        !cPCCode = Trim(txtPCCode)
        !nFreightCharges = 0
        !nFreightAllow = 0
    End With
    
    Do While Not rsDetail.EOF
        With rsDR_T
            .AddNew
            !cCompanyID = COID
            !cDRNo = Trim(cString)
            !cRefNo = Trim(rsHeader!cSONO)
            !nRefIdentity = i
            !cWH = Trim$(rsDetail!cWH)
            !cItemNo = Trim(rsDetail!cItemNo)
            !cDesc = Trim$(rsDetail!cDesc)
            !cLongDesc = IIf(IsNull(rsDetail!cLongDesc), "", Trim(rsDetail!cLongDesc))
            !cUnit = Trim(rsDetail!cUnit)
            !nQty = rsDetail!nQty
            !nPrice = rsDetail!nPrice
            !nAmount = rsDetail!nAmount
            !nCost = 0
            !cCosting = ""
            !cBatchID = ""
            !nFactor = rsDetail!nFactor
            !cBarcodeID = rsDetail!cBarcodeID
        End With
        i = i + 1
        rsDetail.MoveNext
    Loop
    
    rsDR.UpdateBatch adAffectAll
    rsDR_T.UpdateBatch adAffectAll
    
    Set rsDR = Nothing
    Set rsDR_T = Nothing
    
    SOToDR = True
    
FunctionExit:
    Exit Function
    
End Function

Public Sub GetCommission()
    '*************************************
    If rsHeader!cType = "Consignment" Then
        If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'CLNT_MAN_COMMISSION'") = True Then
            If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'CLNT_MAN_USEPARENTCOMPANY'") = True Then
'                If GetValueFrTable("cItemNo", "COMMISSION_CUSTOMER", "cItemNo = '" & rsDetail!cItemNo & "' and cCode = '" & GetValueFrTable("cGroupCode", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'") & "'") <> "" &
                If GetValueFrTable("cGroupCode", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'") <> "" Then
                    If GetValueFrTable("cItemNo", "COMMISSION_CUSTOMER", "cItemNo = '" & rsDetail!cItemNo & "' and cCode = '" & GetValueFrTable("cGroupCode", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'") & "'") <> "" Then
                        rsDetail!cDiscount = GetValueFrTable("nCommission", "COMMISSION_CUSTOMER", "cItemNo = '" & rsDetail!cItemNo & "' and cCode = '" & GetValueFrTable("cGroupCode", "CLIENT_CUSTOMER", "cCode = '" & GetValueFrTable("cGroupCode", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'") & "'") & "'")
                    Else
                        rsDetail!cDiscount = GetValueFrTable("nCommission", "CLIENT_CUSTOMER", "cCode = '" & GetValueFrTable("cGroupCode", "CLIENT_CUSTOMER", "cCode = '" & GetValueFrTable("cGroupCode", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'") & "'") & "'")
                    End If
                Else
                    rsDetail!cDiscount = GetValueFrTable("nCommission", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'")
                End If
            Else
                If GetValueFrTable("cItemNo", "COMMISSION_CUSTOMER", "cItemNo = '" & rsDetail!cItemNo & "' and cCode = '" & GetValueFrTable("cGroupCode", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'") & "'") <> "" Then
                    rsDetail!cDiscount = GetValueFrTable("nCommission", "COMMISSION_CUSTOMER", "cItemNo = '" & rsDetail!cItemNo & "' and cCode = '" & GetValueFrTable("cGroupCode", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'") & "'")
                Else
                    rsDetail!cDiscount = GetValueFrTable("nCommission", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'")
                End If
            End If
        End If
    End If
    '*************************************
End Sub

Private Sub SetVisibleEnable()
    txtAddTo.Visible = GetValueFrTable("lBit", "system_option", "cCode = 'CLNT_OPT_REQUESTEDTO'")
    txtAddToName.Visible = GetValueFrTable("lBit", "system_option", "cCode = 'CLNT_OPT_REQUESTEDTO'")
    cmdPickAddTo.Visible = GetValueFrTable("lBit", "system_option", "cCode = 'CLNT_OPT_REQUESTEDTO'")
End Sub


